Skip to content

Commit

Permalink
fix: allow either access token
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 16, 2023
1 parent 00c61f2 commit 1d1d1bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/commands/org/login/access-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export default class LoginAccessToken extends AuthBaseCommand<AuthFields> {
}

private async getAccessToken(): Promise<string> {
const accessToken = env.getString('SFDX_ACCESS_TOKEN') ?? (await this.askForAccessToken());
const accessToken =
env.getString('SF_ACCESS_TOKEN') ?? env.getString('SFDX_ACCESS_TOKEN') ?? (await this.askForAccessToken());

if (!matchesAccessToken(accessToken)) {
throw new SfError(messages.getMessage('invalidAccessTokenFormat', [ACCESS_TOKEN_FORMAT]));
Expand Down
2 changes: 1 addition & 1 deletion test/commands/org/login/access-token.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('org:login:access-token NUTs', () => {
}
);
accessToken = res.jsonOutput?.result.accessToken as string;
env.setString('SFDX_ACCESS_TOKEN', accessToken);
env.setString('SF_ACCESS_TOKEN', accessToken);
execCmd(`auth:logout -p -o ${username}`, { ensureExitCode: 0 });
});

Expand Down
2 changes: 1 addition & 1 deletion test/commands/org/login/access-token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('org:login:access-token', () => {
// prompt once; one for access token
expect(result).to.deep.equal(authFields);
});
it('should use env var SFDX_ACCESS_TOKEN as input to the store command', async () => {
it('should use env var SF_ACCESS_TOKEN as input to the store command', async () => {
const store = await createNewStoreCommand(
['--instance-url', 'https://foo.bar.org.salesforce.com'],
accessToken,
Expand Down

0 comments on commit 1d1d1bc

Please sign in to comment.