@@ -76,6 +76,32 @@ public class GoogleAuthorizationCodeFlow extends AuthorizationCodeFlow {
7676 */
7777 private final String accessType ;
7878
79+ /**
80+ * @param transport HTTP transport
81+ * @param jsonFactory JSON factory
82+ * @param clientId client identifier
83+ * @param clientSecret client secret
84+ * @param scopes list of scopes to be joined by a space separator (or a single value containing
85+ * multiple space-separated scopes)
86+ *
87+ * @since 1.14
88+ */
89+ public GoogleAuthorizationCodeFlow (HttpTransport transport , JsonFactory jsonFactory ,
90+ String clientId , String clientSecret , Iterable <String > scopes ) {
91+ this (new Builder (transport , jsonFactory , clientId , clientSecret , scopes ));
92+ }
93+
94+ /**
95+ * @param builder Google authorization code flow builder
96+ *
97+ * @since 1.14
98+ */
99+ protected GoogleAuthorizationCodeFlow (Builder builder ) {
100+ super (builder );
101+ accessType = builder .accessType ;
102+ approvalPrompt = builder .approvalPrompt ;
103+ }
104+
79105 /**
80106 * @param method method of presenting the access token to the resource server (for example
81107 * {@link BearerToken#authorizationHeaderAccessMethod})
@@ -94,29 +120,17 @@ public class GoogleAuthorizationCodeFlow extends AuthorizationCodeFlow {
94120 * @param approvalPrompt Prompt for consent behavior ({@code "auto"} to request auto-approval or
95121 * {@code "force"} to force the approval UI to show) or {@code null} for the default
96122 * behavior
123+ * @deprecated (scheduled to be removed in 1.15) Use {@link #GoogleAuthorizationCodeFlow(Builder)}
97124 */
98- protected GoogleAuthorizationCodeFlow (AccessMethod method ,
99- HttpTransport transport ,
100- JsonFactory jsonFactory ,
101- GenericUrl tokenServerUrl ,
102- HttpExecuteInterceptor clientAuthentication ,
103- String clientId ,
104- String authorizationServerEncodedUrl ,
105- CredentialStore credentialStore ,
106- HttpRequestInitializer requestInitializer ,
107- String scopes ,
108- String accessType ,
125+ @ Deprecated
126+ protected GoogleAuthorizationCodeFlow (AccessMethod method , HttpTransport transport ,
127+ JsonFactory jsonFactory , GenericUrl tokenServerUrl ,
128+ HttpExecuteInterceptor clientAuthentication , String clientId ,
129+ String authorizationServerEncodedUrl , CredentialStore credentialStore ,
130+ HttpRequestInitializer requestInitializer , String scopes , String accessType ,
109131 String approvalPrompt ) {
110- super (method ,
111- transport ,
112- jsonFactory ,
113- tokenServerUrl ,
114- clientAuthentication ,
115- clientId ,
116- authorizationServerEncodedUrl ,
117- credentialStore ,
118- requestInitializer ,
119- scopes );
132+ super (method , transport , jsonFactory , tokenServerUrl , clientAuthentication , clientId ,
133+ authorizationServerEncodedUrl , credentialStore , requestInitializer , scopes );
120134 this .accessType = accessType ;
121135 this .approvalPrompt = approvalPrompt ;
122136 }
@@ -125,25 +139,18 @@ protected GoogleAuthorizationCodeFlow(AccessMethod method,
125139 public GoogleAuthorizationCodeTokenRequest newTokenRequest (String authorizationCode ) {
126140 // don't need to specify clientId & clientSecret because specifying clientAuthentication
127141 // don't want to specify redirectUri to give control of it to user of this class
128- return new GoogleAuthorizationCodeTokenRequest (getTransport (),
129- getJsonFactory (),
130- getTokenServerEncodedUrl (),
131- "" ,
132- "" ,
133- authorizationCode ,
134- "" ).setClientAuthentication (getClientAuthentication ())
142+ return new GoogleAuthorizationCodeTokenRequest (getTransport (), getJsonFactory (),
143+ getTokenServerEncodedUrl (), "" , "" , authorizationCode , "" ).setClientAuthentication (
144+ getClientAuthentication ())
135145 .setRequestInitializer (getRequestInitializer ()).setScopes (getScopes ());
136146
137147 }
138148
139149 @ Override
140150 public GoogleAuthorizationCodeRequestUrl newAuthorizationUrl () {
141151 // don't want to specify redirectUri to give control of it to user of this class
142- return new GoogleAuthorizationCodeRequestUrl (getAuthorizationServerEncodedUrl (),
143- getClientId (),
144- "" ,
145- Collections .singleton (getScopes ()))
146- .setAccessType (accessType )
152+ return new GoogleAuthorizationCodeRequestUrl (getAuthorizationServerEncodedUrl (), getClientId (),
153+ "" , Collections .singleton (getScopes ())).setAccessType (accessType )
147154 .setApprovalPrompt (approvalPrompt );
148155 }
149156
@@ -177,13 +184,13 @@ public static class Builder extends AuthorizationCodeFlow.Builder {
177184 * Prompt for consent behavior ({@code "auto"} to request auto-approval or {@code "force"} to
178185 * force the approval UI to show) or {@code null} for the default behavior.
179186 */
180- private String approvalPrompt ;
187+ String approvalPrompt ;
181188
182189 /**
183190 * Access type ({@code "online"} to request online access or {@code "offline"} to request
184191 * offline access) or {@code null} for the default behavior.
185192 */
186- private String accessType ;
193+ String accessType ;
187194
188195 /**
189196 * @param transport HTTP transport
@@ -195,13 +202,9 @@ public static class Builder extends AuthorizationCodeFlow.Builder {
195202 */
196203 public Builder (HttpTransport transport , JsonFactory jsonFactory , String clientId ,
197204 String clientSecret , Iterable <String > scopes ) {
198- super (BearerToken .authorizationHeaderAccessMethod (),
199- transport ,
200- jsonFactory ,
201- new GenericUrl (GoogleOAuthConstants .TOKEN_SERVER_URL ),
202- new ClientParametersAuthentication (clientId , clientSecret ),
203- clientId ,
204- GoogleOAuthConstants .AUTHORIZATION_SERVER_URL );
205+ super (BearerToken .authorizationHeaderAccessMethod (), transport , jsonFactory , new GenericUrl (
206+ GoogleOAuthConstants .TOKEN_SERVER_URL ), new ClientParametersAuthentication (
207+ clientId , clientSecret ), clientId , GoogleOAuthConstants .AUTHORIZATION_SERVER_URL );
205208 setScopes (Preconditions .checkNotNull (scopes ));
206209 }
207210
@@ -214,31 +217,16 @@ public Builder(HttpTransport transport, JsonFactory jsonFactory, String clientId
214217 */
215218 public Builder (HttpTransport transport , JsonFactory jsonFactory ,
216219 GoogleClientSecrets clientSecrets , Iterable <String > scopes ) {
217- super (BearerToken .authorizationHeaderAccessMethod (),
218- transport ,
219- jsonFactory ,
220- new GenericUrl (GoogleOAuthConstants .TOKEN_SERVER_URL ),
221- new ClientParametersAuthentication (clientSecrets .getDetails ().getClientId (),
222- clientSecrets .getDetails ().getClientSecret ()),
223- clientSecrets .getDetails ().getClientId (),
224- GoogleOAuthConstants .AUTHORIZATION_SERVER_URL );
220+ super (BearerToken .authorizationHeaderAccessMethod (), transport , jsonFactory , new GenericUrl (
221+ GoogleOAuthConstants .TOKEN_SERVER_URL ), new ClientParametersAuthentication (
222+ clientSecrets .getDetails ().getClientId (), clientSecrets .getDetails ().getClientSecret ()),
223+ clientSecrets .getDetails ().getClientId (), GoogleOAuthConstants .AUTHORIZATION_SERVER_URL );
225224 setScopes (Preconditions .checkNotNull (scopes ));
226225 }
227226
228227 @ Override
229228 public GoogleAuthorizationCodeFlow build () {
230- return new GoogleAuthorizationCodeFlow (getMethod (),
231- getTransport (),
232- getJsonFactory (),
233- getTokenServerUrl (),
234- getClientAuthentication (),
235- getClientId (),
236- getAuthorizationServerEncodedUrl (),
237- getCredentialStore (),
238- getRequestInitializer (),
239- getScopes (),
240- accessType ,
241- approvalPrompt );
229+ return new GoogleAuthorizationCodeFlow (this );
242230 }
243231
244232 @ Override
0 commit comments