Skip to content

Commit

Permalink
chore: use the default scope the same way
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustrb committed Oct 21, 2024
1 parent 0eb5a20 commit 90f3a49
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ export async function getWorkspaceAccessToken(forceNew = false, scope = '', save

// Note: If no scope is given, it means we should assume the default scope, we store the default scopes
// in the global variable workspaceScopes.
const scopes = scope === '' ? workspaceScopes.join(' ') : scope;
if (scope === '') {
scope = workspaceScopes.join(' ');
}

const workspaceCredentials = await WorkspaceCredentials.getCredentialByScope(scopes);
const workspaceCredentials = await WorkspaceCredentials.getCredentialByScope(scope);
if (workspaceCredentials && !hasWorkspaceAccessTokenExpired(workspaceCredentials) && !forceNew) {
SystemLogger.debug(
`Workspace credentials cache hit using scopes: ${scopes}. Avoiding generating a new access token from cloud services.`,
`Workspace credentials cache hit using scope: ${scope}. Avoiding generating a new access token from cloud services.`,
);
return workspaceCredentials.accessToken;
}

SystemLogger.debug(`Workspace credentials cache miss using scopes: ${scopes}, fetching new access token from cloud services.`);
SystemLogger.debug(`Workspace credentials cache miss using scope: ${scope}, fetching new access token from cloud services.`);

const accessToken = await getWorkspaceAccessTokenWithScope(scope, throwOnError);

Expand Down

0 comments on commit 90f3a49

Please sign in to comment.