@@ -61,25 +61,23 @@ static public OAuth20Service getApiFor20Provider(
61
61
if (providerName .equalsIgnoreCase ("facebook" )) {
62
62
return OAuthManagerProviders .facebookService (params , opts , callbackUrl );
63
63
}
64
-
64
+
65
65
if (providerName .equalsIgnoreCase ("google" )) {
66
66
return OAuthManagerProviders .googleService (params , opts , callbackUrl );
67
67
}
68
-
68
+
69
69
if (providerName .equalsIgnoreCase ("github" )) {
70
70
return OAuthManagerProviders .githubService (params , opts , callbackUrl );
71
71
}
72
-
72
+
73
73
if (providerName .equalsIgnoreCase ("slack" )) {
74
74
return OAuthManagerProviders .slackService (params , opts , callbackUrl );
75
- } else {
76
- return null ;
77
75
}
78
-
76
+
79
77
if (params .containsKey ("access_token_url" ) && params .containsKey ("authorize_url" )) {
80
78
return OAuthManagerProviders .configurableService (params , opts , callbackUrl );
81
79
}
82
-
80
+
83
81
return null ;
84
82
}
85
83
@@ -91,9 +89,9 @@ static public OAuthRequest getRequestForProvider(
91
89
final HashMap <String ,Object > cfg ,
92
90
@ Nullable final ReadableMap params
93
91
) {
94
- final OAuth10aService service =
92
+ final OAuth10aService service =
95
93
OAuthManagerProviders .getApiFor10aProvider (providerName , cfg , null , null );
96
-
94
+
97
95
String token = oa1token .getToken ();
98
96
OAuthConfig config = service .getConfig ();
99
97
OAuthRequest request = new OAuthRequest (httpVerb , url .toString (), config );
@@ -113,14 +111,14 @@ static public OAuthRequest getRequestForProvider(
113
111
) {
114
112
final OAuth20Service service =
115
113
OAuthManagerProviders .getApiFor20Provider (providerName , cfg , null , null );
116
-
114
+
117
115
OAuthConfig config = service .getConfig ();
118
116
OAuthRequest request = new OAuthRequest (httpVerb , url .toString (), config );
119
117
String token = oa2token .getAccessToken ();
120
118
121
119
request = OAuthManagerProviders .addParametersToRequest (request , token , params );
122
120
123
- //
121
+ //
124
122
Log .d (TAG , "Making request for " + providerName + " to add token " + token );
125
123
// Need a way to standardize this, but for now
126
124
if (providerName .equalsIgnoreCase ("slack" )) {
@@ -159,12 +157,12 @@ static private OAuthRequest addParametersToRequest(
159
157
}
160
158
161
159
private static OAuth10aService twitterService (
162
- final HashMap cfg ,
160
+ final HashMap cfg ,
163
161
@ Nullable final ReadableMap opts ,
164
162
final String callbackUrl ) {
165
163
String consumerKey = (String ) cfg .get ("consumer_key" );
166
164
String consumerSecret = (String ) cfg .get ("consumer_secret" );
167
-
165
+
168
166
ServiceBuilder builder = new ServiceBuilder ()
169
167
.apiKey (consumerKey )
170
168
.apiSecret (consumerSecret )
@@ -180,20 +178,20 @@ private static OAuth10aService twitterService(
180
178
if (callbackUrl != null ) {
181
179
builder .callback (callbackUrl );
182
180
}
183
-
181
+
184
182
return builder .build (TwitterApi .instance ());
185
183
}
186
184
187
185
private static OAuth20Service facebookService (
188
- final HashMap cfg ,
186
+ final HashMap cfg ,
189
187
@ Nullable final ReadableMap opts ,
190
188
final String callbackUrl ) {
191
189
ServiceBuilder builder = OAuthManagerProviders ._oauth2ServiceBuilder (cfg , opts , callbackUrl );
192
190
return builder .build (FacebookApi .instance ());
193
191
}
194
192
195
193
private static OAuth20Service googleService (
196
- final HashMap cfg ,
194
+ final HashMap cfg ,
197
195
@ Nullable final ReadableMap opts ,
198
196
final String callbackUrl )
199
197
{
@@ -202,7 +200,7 @@ private static OAuth20Service googleService(
202
200
}
203
201
204
202
private static OAuth20Service githubService (
205
- final HashMap cfg ,
203
+ final HashMap cfg ,
206
204
@ Nullable final ReadableMap opts ,
207
205
final String callbackUrl )
208
206
{
@@ -212,20 +210,27 @@ private static OAuth20Service githubService(
212
210
}
213
211
214
212
private static OAuth20Service configurableService (
215
- final HashMap cfg ,
213
+ final HashMap cfg ,
216
214
@ Nullable final ReadableMap opts ,
217
215
final String callbackUrl
218
216
) {
219
217
ServiceBuilder builder = OAuthManagerProviders ._oauth2ServiceBuilder (cfg , opts , callbackUrl );
218
+ Log .d (TAG , "Creating ConfigurableApi" );
219
+ //Log.d(TAG, " authorize_url: " + cfg.get("authorize_url"));
220
+ //Log.d(TAG, " access_token_url: " + cfg.get("access_token_url"));
220
221
ConfigurableApi api = ConfigurableApi .instance ()
221
222
.setAccessTokenEndpoint ((String ) cfg .get ("access_token_url" ))
222
223
.setAuthorizationBaseUrl ((String ) cfg .get ("authorize_url" ));
223
-
224
+ if (cfg .containsKey ("access_token_verb" )) {
225
+ //Log.d(TAG, " access_token_verb: " + cfg.get("access_token_verb"));
226
+ api .setAccessTokenVerb ((String ) cfg .get ("access_token_verb" ));
227
+ }
228
+
224
229
return builder .build (api );
225
230
}
226
-
231
+
227
232
private static OAuth20Service slackService (
228
- final HashMap cfg ,
233
+ final HashMap cfg ,
229
234
@ Nullable final ReadableMap opts ,
230
235
final String callbackUrl
231
236
) {
@@ -262,13 +267,13 @@ private static ServiceBuilder _oauth2ServiceBuilder(
262
267
String scopeStr = OAuthManagerProviders .getScopeString (scopes , "," );
263
268
builder .scope (scopeStr );
264
269
}
265
-
270
+
266
271
if (opts != null && opts .hasKey ("scopes" )) {
267
272
scopes = (String ) opts .getString ("scopes" );
268
273
String scopeStr = OAuthManagerProviders .getScopeString (scopes , "," );
269
274
builder .scope (scopeStr );
270
275
}
271
-
276
+
272
277
if (callbackUrl != null ) {
273
278
builder .callback (callbackUrl );
274
279
}
@@ -287,4 +292,4 @@ private static String getScopeString(
287
292
Log .d (TAG , "array: " + array + " (" + array .size () + ") from " + scopes );
288
293
return TextUtils .join (joinBy , array );
289
294
}
290
- }
295
+ }
0 commit comments