@@ -67,8 +67,6 @@ public void authorize(
67
67
final Boolean dangerouslyAllowInsecureHttpRequests ,
68
68
final Promise promise
69
69
) {
70
-
71
- final String scopesString = this .arrayToString (scopes );
72
70
final ConnectionBuilder builder = createConnectionBuilder (dangerouslyAllowInsecureHttpRequests );
73
71
final AppAuthConfiguration appAuthConfiguration = this .createAppAuthConfiguration (builder );
74
72
final HashMap <String , String > additionalParametersMap = MapUtils .readableMapToHashMap (additionalParameters );
@@ -90,7 +88,7 @@ public void authorize(
90
88
createAuthorizationServiceConfiguration (serviceConfiguration ),
91
89
appAuthConfiguration ,
92
90
clientId ,
93
- scopesString ,
91
+ scopes ,
94
92
redirectUrl ,
95
93
additionalParametersMap
96
94
);
@@ -114,7 +112,7 @@ public void onFetchConfigurationCompleted(
114
112
fetchedConfiguration ,
115
113
appAuthConfiguration ,
116
114
clientId ,
117
- scopesString ,
115
+ scopes ,
118
116
redirectUrl ,
119
117
additionalParametersMap
120
118
);
@@ -142,7 +140,6 @@ public void refresh(
142
140
final Boolean dangerouslyAllowInsecureHttpRequests ,
143
141
final Promise promise
144
142
) {
145
- final String scopesString = this .arrayToString (scopes );
146
143
final ConnectionBuilder builder = createConnectionBuilder (dangerouslyAllowInsecureHttpRequests );
147
144
final AppAuthConfiguration appAuthConfiguration = createAppAuthConfiguration (builder );
148
145
final HashMap <String , String > additionalParametersMap = MapUtils .readableMapToHashMap (additionalParameters );
@@ -163,7 +160,7 @@ public void refresh(
163
160
appAuthConfiguration ,
164
161
refreshToken ,
165
162
clientId ,
166
- scopesString ,
163
+ scopes ,
167
164
redirectUrl ,
168
165
additionalParametersMap ,
169
166
clientSecret ,
@@ -191,7 +188,7 @@ public void onFetchConfigurationCompleted(
191
188
appAuthConfiguration ,
192
189
refreshToken ,
193
190
clientId ,
194
- scopesString ,
191
+ scopes ,
195
192
redirectUrl ,
196
193
additionalParametersMap ,
197
194
clientSecret ,
@@ -258,11 +255,17 @@ private void authorizeWithConfiguration(
258
255
final AuthorizationServiceConfiguration serviceConfiguration ,
259
256
final AppAuthConfiguration appAuthConfiguration ,
260
257
final String clientId ,
261
- final String scopesString ,
258
+ final ReadableArray scopes ,
262
259
final String redirectUrl ,
263
260
final Map <String , String > additionalParametersMap
264
261
) {
265
262
263
+ String scopesString = null ;
264
+
265
+ if (scopes != null ) {
266
+ scopesString = this .arrayToString (scopes );
267
+ }
268
+
266
269
final Context context = this .reactContext ;
267
270
final Activity currentActivity = getCurrentActivity ();
268
271
@@ -272,8 +275,12 @@ private void authorizeWithConfiguration(
272
275
clientId ,
273
276
ResponseTypeValues .CODE ,
274
277
Uri .parse (redirectUrl )
275
- )
276
- .setScope (scopesString );
278
+ );
279
+
280
+ if (scopesString != null ) {
281
+ authRequestBuilder .setScope (scopesString );
282
+ }
283
+
277
284
278
285
if (additionalParametersMap != null ) {
279
286
// handle additional parameters separately to avoid exceptions from AppAuth
@@ -316,24 +323,33 @@ private void refreshWithConfiguration(
316
323
final AppAuthConfiguration appAuthConfiguration ,
317
324
final String refreshToken ,
318
325
final String clientId ,
319
- final String scopesString ,
326
+ final ReadableArray scopes ,
320
327
final String redirectUrl ,
321
328
final Map <String , String > additionalParametersMap ,
322
329
final String clientSecret ,
323
330
final Promise promise
324
331
) {
325
332
333
+ String scopesString = null ;
334
+
335
+ if (scopes != null ) {
336
+ scopesString = this .arrayToString (scopes );
337
+ }
338
+
326
339
final Context context = this .reactContext ;
327
340
328
341
TokenRequest .Builder tokenRequestBuilder =
329
342
new TokenRequest .Builder (
330
343
serviceConfiguration ,
331
344
clientId
332
345
)
333
- .setScope (scopesString )
334
346
.setRefreshToken (refreshToken )
335
347
.setRedirectUri (Uri .parse (redirectUrl ));
336
348
349
+ if (scopesString != null ) {
350
+ tokenRequestBuilder .setScope (scopesString );
351
+ }
352
+
337
353
if (!additionalParametersMap .isEmpty ()) {
338
354
tokenRequestBuilder .setAdditionalParameters (additionalParametersMap );
339
355
}
0 commit comments