2727
2828/**
2929 * The supported formats for the returned OAuth2 token.
30- * @type { Object.< string, string> }
30+ * @enum { string}
3131 */
3232var TOKEN_FORMAT = {
33+ /** JSON format, for example <code>{"access_token": "..."}</code> **/
3334 JSON : 'application/json' ,
35+ /** Form URL-encoded, for example <code>access_token=...</code> **/
3436 FORM_URL_ENCODED : 'application/x-www-form-urlencoded'
3537} ;
3638
3739/**
3840 * The supported locations for passing the state parameter.
39- * @type { Object.< string, string> }
41+ * @enum { string}
4042 */
4143var STATE_PARAMETER_LOCATION = {
44+ /**
45+ * Pass the state parameter in the authorization URL.
46+ * @default
47+ */
4248 AUTHORIZATION_URL : 'authorization-url' ,
49+ /** Pass the state token in the redirect URL, as a workaround for APIs that don't support the state parameter. */
4350 REDIRECT_URL : 'redirect-url'
4451} ;
4552
@@ -153,17 +160,28 @@ Service_.prototype.setTokenFormat = function(tokenFormat) {
153160/**
154161 * Sets the additional HTTP headers that should be sent when retrieving or
155162 * refreshing the access token.
156- * @param Object.<string,string> tokenHeaders A map of header names to values.
163+ * @param { Object.<string,string> } tokenHeaders A map of header names to values.
157164 * @return {Service_ } This service, for chaining.
158165 */
159166Service_ . prototype . setTokenHeaders = function ( tokenHeaders ) {
160167 this . tokenHeaders_ = tokenHeaders ;
161168 return this ;
162169} ;
163170
171+ /**
172+ * @callback tokenHandler
173+ * @param tokenPayload {Object} A hash of parameters to be sent to the token URL.
174+ * @param tokenPayload.code {string} The authorization code.
175+ * @param tokenPayload.client_id {string} The client ID.
176+ * @param tokenPayload.client_secret {string} The client secret.
177+ * @param tokenPayload.redirect_uri {string} The redirect URI.
178+ * @param tokenPayload.grant_type {string} The type of grant requested.
179+ * @returns {Object } A modified hash of parameters to be sent to the token URL.
180+ */
181+
164182/**
165183 * Sets an additional function to invoke on the payload of the access token request.
166- * @param Object tokenHandler A function to invoke on the payload of the request for an access token.
184+ * @param tokenHandler {tokenHandler} tokenHandler A function to invoke on the payload of the request for an access token.
167185 * @return {Service_ } This service, for chaining.
168186 */
169187Service_ . prototype . setTokenPayloadHandler = function ( tokenHandler ) {
@@ -436,7 +454,11 @@ Service_.prototype.reset = function() {
436454 validate_ ( {
437455 'Property store' : this . propertyStore_
438456 } ) ;
439- this . propertyStore_ . deleteProperty ( this . getPropertyKey_ ( this . serviceName_ ) ) ;
457+ var key = this . getPropertyKey_ ( this . serviceName_ ) ;
458+ this . propertyStore_ . deleteProperty ( key ) ;
459+ if ( this . cache_ ) {
460+ this . cache_ . remove ( key ) ;
461+ }
440462} ;
441463
442464/**
@@ -449,9 +471,9 @@ Service_.prototype.getLastError = function() {
449471} ;
450472
451473/**
452- * Gets the last error that occurred this execution when trying to automatically refresh
453- * or generate an access token .
454- * @return {Exception } An error, if any .
474+ * Returns the redirect URI that will be used for this service. Often this URI
475+ * needs to be entered into a configuration screen of your OAuth provider .
476+ * @return {string } The redirect URI .
455477 */
456478Service_ . prototype . getRedirectUri = function ( ) {
457479 return getRedirectUri ( this . scriptId_ ) ;
@@ -627,6 +649,7 @@ Service_.prototype.isExpired_ = function(token) {
627649/**
628650 * Uses the service account flow to exchange a signed JSON Web Token (JWT) for an
629651 * access token.
652+ * @private
630653 */
631654Service_ . prototype . exchangeJwt_ = function ( ) {
632655 validate_ ( {
0 commit comments