Skip to content

Commit

Permalink
Sm/docs-fix (#864)
Browse files Browse the repository at this point in the history
* fix: docs for access token env

* fix: allow either access token
  • Loading branch information
mshanemc authored Nov 20, 2023
1 parent 8d9d8a4 commit dc094d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion messages/accesstoken.store.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To use the command in a CI/CD script, set the SFDX_ACCESS_TOKEN environment vari

<%= config.bin %> <%= command.id %> --instance-url https://mycompany.my.salesforce.com

- Authorize the org without being prompted; you must have previously set the SFDX_ACCESS_TOKEN environment variable to the access token:
- Authorize the org without being prompted; you must have previously set the SF_ACCESS_TOKEN environment variable to the access token:

<%= config.bin %> <%= command.id %> --instance-url https://dev-hub.my.salesforce.com --no-prompt

Expand Down
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 dc094d6

Please sign in to comment.