diff --git a/src/Service.js b/src/Service.js index bfe034fc..5f31e47a 100644 --- a/src/Service.js +++ b/src/Service.js @@ -457,6 +457,20 @@ Service_.prototype.getAccessToken = function() { return token.access_token; }; +/** + * Gets an id token for this service. This token can be used in HTTP + * requests to the service's endpoint. This method will throw an error if the + * user's access was not granted or has expired. + * @return {string} An id token. + */ +Service_.prototype.getIdToken = function() { + if (!this.hasAccess()) { + throw new Error('Access not granted or expired.'); + } + var token = this.getToken(); + return token.id_token; +}; + /** * Resets the service, removing access and requiring the service to be * re-authorized.