Skip to content
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

feat: do not deprecate refreshAccessToken #804

Merged
merged 3 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,13 @@ const client = await auth.getClient({
});
```

#### The `refreshAccessToken` method has been deprecated
The `OAuth2.refreshAccessToken` method has been deprecated. The `getAccessToken`, `getRequestMetadata`, and `request` methods will all refresh the token if needed automatically. There is no need to ever manually refresh the token.
#### Deprecate `refreshAccessToken`

As always, if you run into any problems... please let us know!
_Note: `refreshAccessToken` is no longer deprecated._

`getAccessToken`, `getRequestMetadata`, and `request` methods will all refresh the token if needed automatically.

You should not need to invoke `refreshAccessToken` directly except in [certain edge-cases](https://github.com/googleapis/google-auth-library-nodejs/issues/575).

### Features
- Set private_key_id in JWT access token header like other google auth libraries. (#450)
Expand Down
1 change: 0 additions & 1 deletion src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ export class OAuth2Client extends AuthClient {
refreshAccessToken(
callback?: RefreshAccessTokenCallback
): Promise<RefreshAccessTokenResponse> | void {
messages.warn(messages.REFRESH_ACCESS_TOKEN_DEPRECATED);
if (callback) {
this.refreshAccessTokenAsync().then(
r => callback(null, r.credentials, r.res),
Expand Down
9 changes: 0 additions & 9 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ export const JWT_ACCESS_CREATE_SCOPED_DEPRECATED = {
].join(' '),
};

export const REFRESH_ACCESS_TOKEN_DEPRECATED = {
code: 'google-auth-library:DEP007',
type: WarningTypes.DEPRECATION,
message: [
'The `refreshAccessToken` method has been deprecated, and will be removed',
'in the 3.0 release of google-auth-library. Please use the `getRequestHeaders`',
'method instead.',
].join(' '),
};
export const OAUTH_GET_REQUEST_METADATA_DEPRECATED = {
code: 'google-auth-library:DEP004',
type: WarningTypes.DEPRECATION,
Expand Down
23 changes: 20 additions & 3 deletions test/test.googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,33 @@ describe('googleauth', () => {

return {
done: () => {
primary.done();
secondary.done();
try {
primary.done();
secondary.done();
} catch (err) {
// secondary can sometimes complete prior to primary.
}
},
};
}

function nock404GCE() {
return nock(host)
const primary = nock(host)
.get(instancePath)
.reply(404);
const secondary = nock(SECONDARY_HOST_ADDRESS)
.get(instancePath)
.reply(404);
return {
done: () => {
try {
primary.done();
secondary.done();
} catch (err) {
// secondary can sometimes complete prior to primary.
}
},
};
}

function createGetProjectIdNock(projectId = 'not-real') {
Expand Down
4 changes: 2 additions & 2 deletions test/test.oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,11 +865,11 @@ describe(__filename, () => {
});
});

it('should emit warning on refreshAccessToken', async () => {
it('should not emit warning on refreshAccessToken', async () => {
let warned = false;
sandbox.stub(process, 'emitWarning').callsFake(() => (warned = true));
client.refreshAccessToken((err, result) => {
assert.strictEqual(warned, true);
assert.strictEqual(warned, false);
});
});

Expand Down