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

Fix usage of OAuth2Client.verifyIdToken in example #243

Merged
merged 2 commits into from
Jan 15, 2018

Conversation

aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Jan 10, 2018

examples/verifyIdToken.js uses the old signature for OAuth2Client.verifyIdToken, this PR upgrades it to the new API.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 10, 2018
@JustinBeckwith
Copy link
Contributor

Thank you for catching this :) Could you also add the audience in the new options?

const ticket = await oAuth2Client.verifyIdToken({
  idToken: oAuth2Client.credentials.id_token,
  audience: keys.web.client_id
});

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 11, 2018

@JustinBeckwith I added a part audience: 'audience' to the verifyIdToken options, as I don't know what would be a sensible value for audience. Does this look OK to you or should I use some other value?

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 11, 2018

@JustinBeckwith I'm also wondering if verifyIdToken should be documented somewhere? I only find it in examples and tests.

@JustinBeckwith
Copy link
Contributor

The audience should be set to keys.web.client_id :) On the docs piece - the readme can always be better, but at least we have a proper reference doc now at google.github.io/google-auth-library-nodejs/

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 12, 2018

@JustinBeckwith Oh, alright, I've updated the PR. The verifyIdToken test (test.oauth2.ts) doesn't follow this pattern though, should it be changed to read const result = await client.verifyIdToken({idToken, audience: CLIENT_ID, maxExpiry}); to be consistent?

I mean, when I read the test, I don't get the impression that the audience should correspond to the client ID so it's confusing :)

@JustinBeckwith JustinBeckwith merged commit 64fb34d into googleapis:master Jan 15, 2018
@Boboss74
Copy link

Boboss74 commented Feb 14, 2018

omg this is why it doesn't work... T-T

So, this doc need some update too
https://developers.google.com/identity/sign-in/web/backend-auth#send-the-id-token-to-your-server

@aknuds1 aknuds1 deleted the fix-example-verify-id-token branch February 14, 2018 18:25
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.

4 participants