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: emit an event when new tokens are obtained #341

Merged
merged 5 commits into from
Apr 6, 2018
Merged

feat: emit an event when new tokens are obtained #341

merged 5 commits into from
Apr 6, 2018

Conversation

JustinBeckwith
Copy link
Contributor

Today we really have no way to tell users when their access_token was refreshed. Some people store these on the server across multiple requests, so giving them some way to know when it happens would be nice. Users are asking for this over in google-api-nodejs-client.

Resolves #340.

@JustinBeckwith JustinBeckwith requested review from ofrobots and a team April 4, 2018 22:53
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 4, 2018
@codecov-io
Copy link

codecov-io commented Apr 4, 2018

Codecov Report

Merging #341 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #341      +/-   ##
==========================================
+ Coverage   94.72%   94.75%   +0.02%     
==========================================
  Files          14       14              
  Lines         948      953       +5     
  Branches      195      196       +1     
==========================================
+ Hits          898      903       +5     
  Misses         50       50
Impacted Files Coverage Δ
src/auth/jwtclient.ts 94.05% <100%> (+0.05%) ⬆️
src/auth/authclient.ts 100% <100%> (ø) ⬆️
src/auth/oauth2client.ts 94.38% <100%> (+0.03%) ⬆️
src/auth/computeclient.ts 95.55% <100%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b057e7...3e03866. Read the comment docs.

@JustinBeckwith JustinBeckwith requested review from a team and alexander-fenster and removed request for a team April 6, 2018 17:28
@@ -551,6 +552,9 @@ export class OAuth2Client extends AuthClient {
((new Date()).getTime() + (res.data.expires_in * 1000));
delete (tokens as CredentialRequest).expires_in;
}

this.emit('tokens', tokens);

This comment was marked as spam.

test/test.jwt.ts Outdated
let raisedEvent = false;
jwt.on('tokens', tokens => {
assert.equal(tokens.access_token, 'initial-access-token');
raisedEvent = true;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


// ensure the tokens event is raised
client.on('tokens', tokens => {
assert.equal(tokens.access_token, 'abc123');

This comment was marked as spam.

@JustinBeckwith JustinBeckwith merged commit 2570751 into googleapis:master Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants