@@ -112,6 +112,9 @@ public class AuthorizationCodeFlow {
112112 /** Refresh listeners provided by the client. */
113113 private final Collection <CredentialRefreshListener > refreshListeners ;
114114
115+ /** Additional parameters to pass to authorization url. */
116+ private final Map <String , String > additionalParameters ;
117+
115118 /**
116119 * @param method method of presenting the access token to the resource server (for example {@link
117120 * BearerToken#authorizationHeaderAccessMethod})
@@ -131,7 +134,8 @@ public AuthorizationCodeFlow(
131134 GenericUrl tokenServerUrl ,
132135 HttpExecuteInterceptor clientAuthentication ,
133136 String clientId ,
134- String authorizationServerEncodedUrl ) {
137+ String authorizationServerEncodedUrl ,
138+ Map <String , String > additionalParameters ) {
135139 this (
136140 new Builder (
137141 method ,
@@ -140,7 +144,8 @@ public AuthorizationCodeFlow(
140144 tokenServerUrl ,
141145 clientAuthentication ,
142146 clientId ,
143- authorizationServerEncodedUrl ));
147+ authorizationServerEncodedUrl ,
148+ additionalParameters ));
144149 }
145150
146151 /**
@@ -156,6 +161,7 @@ protected AuthorizationCodeFlow(Builder builder) {
156161 clientId = Preconditions .checkNotNull (builder .clientId );
157162 authorizationServerEncodedUrl =
158163 Preconditions .checkNotNull (builder .authorizationServerEncodedUrl );
164+ additionalParameters = Preconditions .checkNotNull (builder .additionalParameters );
159165 requestInitializer = builder .requestInitializer ;
160166 credentialStore = builder .credentialStore ;
161167 credentialDataStore = builder .credentialDataStore ;
@@ -192,6 +198,11 @@ public AuthorizationCodeRequestUrl newAuthorizationUrl() {
192198 url .setCodeChallenge (pkce .getChallenge ());
193199 url .setCodeChallengeMethod (pkce .getChallengeMethod ());
194200 }
201+ if (additionalParameters != null ) {
202+ for (Map .Entry <String , String > entry : additionalParameters .entrySet ()) {
203+ url .put (entry .getKey (), entry .getValue ());
204+ }
205+ }
195206 return url ;
196207 }
197208
@@ -549,6 +560,9 @@ public static class Builder {
549560 /** Refresh listeners provided by the client. */
550561 Collection <CredentialRefreshListener > refreshListeners = Lists .newArrayList ();
551562
563+ /** Additional authorization url parameters provided by the client **/
564+ Map <String , String > additionalParameters ;
565+
552566 /**
553567 * @param method method of presenting the access token to the resource server (for example
554568 * {@link BearerToken#authorizationHeaderAccessMethod})
@@ -567,14 +581,16 @@ public Builder(
567581 GenericUrl tokenServerUrl ,
568582 HttpExecuteInterceptor clientAuthentication ,
569583 String clientId ,
570- String authorizationServerEncodedUrl ) {
584+ String authorizationServerEncodedUrl ,
585+ Map <String , String > additionalParameters ) {
571586 setMethod (method );
572587 setTransport (transport );
573588 setJsonFactory (jsonFactory );
574589 setTokenServerUrl (tokenServerUrl );
575590 setClientAuthentication (clientAuthentication );
576591 setClientId (clientId );
577592 setAuthorizationServerEncodedUrl (authorizationServerEncodedUrl );
593+ setAdditionalParameters (additionalParameters );
578594 }
579595
580596 /** Returns a new instance of an authorization code flow based on this builder. */
@@ -717,6 +733,20 @@ public Builder setAuthorizationServerEncodedUrl(String authorizationServerEncode
717733 return this ;
718734 }
719735
736+ /**
737+ * Sets the additional url parameters.
738+ *
739+ * <p>Overriding is only supported for the purpose of calling the super implementation and
740+ * changing the return type, but nothing else.
741+ *
742+ * @since 1.11
743+ */
744+ public Builder setAdditionalParameters (Map <String , String > additionalParameters ) {
745+ this .additionalParameters =
746+ Preconditions .checkNotNull (additionalParameters );
747+ return this ;
748+ }
749+
720750 /**
721751 * {@link Beta} <br>
722752 * Returns the credential persistence store or {@code null} for none.
0 commit comments