Skip to content

Commit

Permalink
docs(samples): fix iap verify sample (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Feb 18, 2020
1 parent 0368864 commit 627277f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions samples/verifyIdToken-iap.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ function main(

const oAuth2Client = new OAuth2Client();

async function verifyIdToken() {
async function verify() {
// Verify the id_token, and access the claims.
const response = await oAuth2Client.getIapPublicKeys();
return await oAuth2Client.verifySignedJwtWithCertsAsync(
const ticket = await oAuth2Client.verifySignedJwtWithCertsAsync(
iapJwt,
response.pubkeys,
expectedAudience,
['https://cloud.google.com/iap']
);
// Print out the info contained in the IAP ID token
console.log(ticket);
}

const ticket = verifyIdToken();
// Print out the info contained in the IAP ID token
console.log(ticket);
verify().catch(console.error);

// [END iap_validate_jwt]
if (!expectedAudience) {
console.log(
Expand All @@ -70,4 +71,4 @@ function main(
}

const args = process.argv.slice(2);
main(...args).catch(console.error);
main(...args);

0 comments on commit 627277f

Please sign in to comment.