Skip to content

Commit 68c1baa

Browse files
feat: add functionality to cache token
1 parent 9641f3c commit 68c1baa

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/cli/src/commands/scorecard-classic/auth/login-handler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import type { Config } from '@redocly/openapi-core';
99
export async function handleLoginAndFetchToken(config: Config): Promise<string | undefined> {
1010
const reuniteUrl = getReuniteUrl(config, config.resolvedConfig?.residency);
1111
const oauthClient = new RedoclyOAuthClient();
12-
const isAuthorized = await oauthClient.isAuthorized(reuniteUrl);
12+
let accessToken = await oauthClient.getAccessToken(reuniteUrl);
1313

14-
if (!isAuthorized) {
14+
if (!accessToken) {
1515
logger.info(`\n${blue('Authentication required to fetch remote scorecard configuration.')}\n`);
1616
logger.info(`Please login to continue:\n`);
1717

1818
try {
1919
await oauthClient.login(reuniteUrl);
20+
accessToken = await oauthClient.getAccessToken(reuniteUrl);
2021
} catch (error) {
2122
exitWithError(`Login failed. Please try again or check your connection to ${reuniteUrl}.`);
2223
}
2324
}
2425

25-
const token = await oauthClient.getAccessToken(reuniteUrl);
26-
return token === null ? undefined : token;
26+
return accessToken === null ? undefined : accessToken;
2727
}

0 commit comments

Comments
 (0)