Skip to content

Commit f05de11

Browse files
author
Benjamin E. Coe
authored
feat: do not deprecate refreshAccessToken (#804)
1 parent d754771 commit f05de11

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,13 @@ const client = await auth.getClient({
399399
});
400400
```
401401

402-
#### The `refreshAccessToken` method has been deprecated
403-
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.
402+
#### Deprecate `refreshAccessToken`
404403

405-
As always, if you run into any problems... please let us know!
404+
_Note: `refreshAccessToken` is no longer deprecated._
405+
406+
`getAccessToken`, `getRequestMetadata`, and `request` methods will all refresh the token if needed automatically.
407+
408+
You should not need to invoke `refreshAccessToken` directly except in [certain edge-cases](https://github.com/googleapis/google-auth-library-nodejs/issues/575).
406409

407410
### Features
408411
- Set private_key_id in JWT access token header like other google auth libraries. (#450)

src/auth/oauth2client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ export class OAuth2Client extends AuthClient {
640640
refreshAccessToken(
641641
callback?: RefreshAccessTokenCallback
642642
): Promise<RefreshAccessTokenResponse> | void {
643-
messages.warn(messages.REFRESH_ACCESS_TOKEN_DEPRECATED);
644643
if (callback) {
645644
this.refreshAccessTokenAsync().then(
646645
r => callback(null, r.credentials, r.res),

src/messages.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ export const JWT_ACCESS_CREATE_SCOPED_DEPRECATED = {
102102
].join(' '),
103103
};
104104

105-
export const REFRESH_ACCESS_TOKEN_DEPRECATED = {
106-
code: 'google-auth-library:DEP007',
107-
type: WarningTypes.DEPRECATION,
108-
message: [
109-
'The `refreshAccessToken` method has been deprecated, and will be removed',
110-
'in the 3.0 release of google-auth-library. Please use the `getRequestHeaders`',
111-
'method instead.',
112-
].join(' '),
113-
};
114105
export const OAUTH_GET_REQUEST_METADATA_DEPRECATED = {
115106
code: 'google-auth-library:DEP004',
116107
type: WarningTypes.DEPRECATION,

test/test.googleauth.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,33 @@ describe('googleauth', () => {
203203

204204
return {
205205
done: () => {
206-
primary.done();
207-
secondary.done();
206+
try {
207+
primary.done();
208+
secondary.done();
209+
} catch (err) {
210+
// secondary can sometimes complete prior to primary.
211+
}
208212
},
209213
};
210214
}
211215

212216
function nock404GCE() {
213-
return nock(host)
217+
const primary = nock(host)
214218
.get(instancePath)
215219
.reply(404);
220+
const secondary = nock(SECONDARY_HOST_ADDRESS)
221+
.get(instancePath)
222+
.reply(404);
223+
return {
224+
done: () => {
225+
try {
226+
primary.done();
227+
secondary.done();
228+
} catch (err) {
229+
// secondary can sometimes complete prior to primary.
230+
}
231+
},
232+
};
216233
}
217234

218235
function createGetProjectIdNock(projectId = 'not-real') {

test/test.oauth2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,11 +865,11 @@ describe(__filename, () => {
865865
});
866866
});
867867

868-
it('should emit warning on refreshAccessToken', async () => {
868+
it('should not emit warning on refreshAccessToken', async () => {
869869
let warned = false;
870870
sandbox.stub(process, 'emitWarning').callsFake(() => (warned = true));
871871
client.refreshAccessToken((err, result) => {
872-
assert.strictEqual(warned, true);
872+
assert.strictEqual(warned, false);
873873
});
874874
});
875875

0 commit comments

Comments
 (0)