Skip to content

W-17605467 fix: refresh access token before issuing request #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/commands/api/request/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default class Graphql extends SfCommand<void> {
.replaceAll('"', '\\"')}"}`;
const url = new URL(`${org.getField<string>(Org.Fields.INSTANCE_URL)}/services/data/v${apiVersion}/graphql`);

// refresh access token to ensure `got` gets a valid access token.
// TODO: we could skip this step if we used jsforce's HTTP module instead (handles expired tokens).
await org.refreshAuth();

const options = {
Expand Down
6 changes: 4 additions & 2 deletions src/commands/api/request/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export class Rest extends SfCommand<void> {
headers = { ...headers, ...body.getHeaders() };
}

// refresh access token to ensure `got` gets a valid access token.
// TODO: we could skip this step if we used jsforce's HTTP module instead (handles expired tokens).
await org.refreshAuth();

const options = {
agent: { https: new ProxyAgent() },
method,
Expand All @@ -155,8 +159,6 @@ export class Rest extends SfCommand<void> {
followRedirect: false,
};

await org.refreshAuth();

await sendAndPrintRequest({ streamFile, url, options, include: flags.include, this: this });
}
}
Expand Down
Loading