Skip to content

Commit da47858

Browse files
authored
Fixes the procedure of refreshing an access token in GK integration (#3357)
* Fixes the procedure of refreshing an access token in GK integration (GLVSC-569) * Upgrade the changelog (GLVSC-569)
1 parent a4e1365 commit da47858

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2727
### Fixed
2828

2929
- Fixes [#3344](https://github.com/gitkraken/vscode-gitlens/issues/3344) - Make changing the AI key easier
30+
- Fixes fixes issue with Jira integration not refreshing
3031

3132
## [15.1.0] - 2024-06-05
3233

src/plus/integrations/authentication/cloudIntegrationService.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,26 @@ export class CloudIntegrationService {
3535

3636
async getConnectionSession(
3737
id: IntegrationId,
38-
refresh: boolean = false,
38+
refreshToken?: string,
3939
): Promise<CloudIntegrationAuthenticationSession | undefined> {
40+
const refresh = Boolean(refreshToken);
4041
const cloudIntegrationType = toCloudIntegrationType[id];
4142
if (cloudIntegrationType == null) {
4243
Logger.error(`Unsupported cloud integration type: ${id}`);
4344
return undefined;
4445
}
46+
const reqInitOptions = refreshToken
47+
? {
48+
method: 'POST',
49+
body: JSON.stringify({
50+
access_token: refreshToken,
51+
}),
52+
}
53+
: { method: 'GET' };
4554

4655
const tokenRsp = await this.connection.fetchGkDevApi(
4756
`v1/provider-tokens/${cloudIntegrationType}${refresh ? '/refresh' : ''}`,
48-
{ method: refresh ? 'POST' : 'GET' },
57+
reqInitOptions,
4958
{ organizationId: false },
5059
);
5160
if (!tokenRsp.ok) {

src/plus/integrations/authentication/jira.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class JiraAuthenticationProvider implements IntegrationAuthenticationProv
3030
let session = await cloudIntegrations.getConnectionSession(this.authProviderId);
3131

3232
if (session != null && session.expiresIn < 60) {
33-
session = await cloudIntegrations.getConnectionSession(this.authProviderId, true);
33+
session = await cloudIntegrations.getConnectionSession(this.authProviderId, session.accessToken);
3434
}
3535

3636
if (!session && options?.authorizeIfNeeded) {

0 commit comments

Comments
 (0)