@@ -306,9 +306,11 @@ Service_.prototype.setGrantType = function(grantType) {
306306 * have the user visit this URL and approve the authorization request. The 
307307 * user will then be redirected back to your application using callback function 
308308 * name specified, so that the flow may continue. 
309+  * @param  {Object } optAdditionalParameters Additional parameters that should be 
310+  * stored in the state token and made available in the callback function. 
309311 * @return  {string } The authorization URL. 
310312 */ 
311- Service_ . prototype . getAuthorizationUrl  =  function ( )  { 
313+ Service_ . prototype . getAuthorizationUrl  =  function ( optAdditionalParameters )  { 
312314 validate_ ( { 
313315 'Client ID' : this . clientId_ , 
314316 'Script ID' : this . scriptId_ , 
@@ -317,16 +319,20 @@ Service_.prototype.getAuthorizationUrl = function() {
317319 } ) ; 
318320
319321 var  redirectUri  =  getRedirectUri ( this . scriptId_ ) ; 
320-  var  state  =  eval ( 'Script'  +  'App' ) . newStateToken ( ) 
322+  var  stateTokenBuilder  =  eval ( 'Script'  +  'App' ) . newStateToken ( ) 
321323 . withMethod ( this . callbackFunctionName_ ) 
322324 . withArgument ( 'serviceName' ,  this . serviceName_ ) 
323-  . withTimeout ( 3600 ) 
324-  . createToken ( ) ; 
325+  . withTimeout ( 3600 ) ; 
326+  if  ( optAdditionalParameters )  { 
327+  Object . keys ( optAdditionalParameters ) . forEach ( function ( key )  { 
328+  stateTokenBuilder . withArgument ( key ,  optAdditionalParameters [ key ] ) ; 
329+  } ) ; 
330+  } 
325331 var  params  =  { 
326332 client_id : this . clientId_ , 
327333 response_type : 'code' , 
328334 redirect_uri : redirectUri , 
329-  state : state 
335+  state : stateTokenBuilder . createToken ( ) 
330336 } ; 
331337 params  =  extend_ ( params ,  this . params_ ) ; 
332338 return  buildUrl_ ( this . authorizationBaseUrl_ ,  params ) ; 
0 commit comments