Skip to content

Commit 551a4cb

Browse files
author
Eric Koleda
authored
Merge pull request #200 from mryerse/patch-1
Add function to return id_token (for Service Now)
2 parents 972d837 + 73013c9 commit 551a4cb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Service.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,20 @@ Service_.prototype.getAccessToken = function() {
457457
return token.access_token;
458458
};
459459

460+
/**
461+
* Gets an id token for this service. This token can be used in HTTP
462+
* requests to the service's endpoint. This method will throw an error if the
463+
* user's access was not granted or has expired.
464+
* @return {string} An id token.
465+
*/
466+
Service_.prototype.getIdToken = function() {
467+
if (!this.hasAccess()) {
468+
throw new Error('Access not granted or expired.');
469+
}
470+
var token = this.getToken();
471+
return token.id_token;
472+
};
473+
460474
/**
461475
* Resets the service, removing access and requiring the service to be
462476
* re-authorized.

0 commit comments

Comments
 (0)