@@ -187,7 +187,7 @@ public void onFetchConfigurationCompleted(
187
187
@ Nullable AuthorizationServiceConfiguration fetchedConfiguration ,
188
188
@ Nullable AuthorizationException ex ) {
189
189
if (ex != null ) {
190
- promise .reject ("Failed to fetch configuration" , ex . errorDescription );
190
+ promise .reject ("Failed to fetch configuration" , getErrorMessage ( ex ) );
191
191
return ;
192
192
}
193
193
@@ -269,7 +269,7 @@ public void onFetchConfigurationCompleted(
269
269
@ Nullable AuthorizationServiceConfiguration fetchedConfiguration ,
270
270
@ Nullable AuthorizationException ex ) {
271
271
if (ex != null ) {
272
- promise .reject ("Failed to fetch configuration" , ex . errorDescription );
272
+ promise .reject ("Failed to fetch configuration" , getErrorMessage ( ex ) );
273
273
return ;
274
274
}
275
275
@@ -303,7 +303,7 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,
303
303
final AuthorizationResponse response = AuthorizationResponse .fromIntent (data );
304
304
AuthorizationException exception = AuthorizationException .fromIntent (data );
305
305
if (exception != null ) {
306
- promise .reject ("Failed to authenticate" , exception . errorDescription );
306
+ promise .reject ("Failed to authenticate" , getErrorMessage ( exception ) );
307
307
return ;
308
308
}
309
309
@@ -325,7 +325,7 @@ public void onTokenRequestCompleted(
325
325
WritableMap map = TokenResponseFactory .tokenResponseToMap (resp , response );
326
326
authorizePromise .resolve (map );
327
327
} else {
328
- promise .reject ("Failed exchange token" , ex . errorDescription );
328
+ promise .reject ("Failed exchange token" , getErrorMessage ( ex ) );
329
329
}
330
330
}
331
331
};
@@ -464,7 +464,7 @@ public void onTokenRequestCompleted(@Nullable TokenResponse response, @Nullable
464
464
WritableMap map = TokenResponseFactory .tokenResponseToMap (response );
465
465
promise .resolve (map );
466
466
} else {
467
- promise .reject ("Failed to refresh token" , ex . errorDescription );
467
+ promise .reject ("Failed to refresh token" , getErrorMessage ( ex ) );
468
468
}
469
469
}
470
470
};
@@ -500,6 +500,15 @@ private ClientAuthentication getClientAuthentication(String clientSecret, String
500
500
return new ClientSecretBasic (clientSecret );
501
501
}
502
502
503
+ /*
504
+ * Return error information if it is available
505
+ */
506
+ private String getErrorMessage (AuthorizationException ex ){
507
+ if (ex .errorDescription == null && ex .error != null )
508
+ return ex .error ;
509
+ return ex .errorDescription ;
510
+ }
511
+
503
512
/*
504
513
* Create a space-delimited string from an array
505
514
*/
0 commit comments