23
23
import java .util .List ;
24
24
import java .util .ArrayList ;
25
25
26
+ import com .google .gson .Gson ;
27
+
26
28
import com .facebook .react .bridge .Arguments ;
27
29
import com .facebook .react .bridge .LifecycleEventListener ;
28
30
import com .facebook .react .bridge .ReactApplicationContext ;
@@ -417,15 +419,17 @@ private WritableMap accessTokenResponse(
417
419
) {
418
420
WritableMap resp = Arguments .createMap ();
419
421
WritableMap response = Arguments .createMap ();
422
+ Map accessTokenMap = new Gson ().fromJson (accessToken .getRawResponse (), Map .class );
420
423
421
424
Log .d (TAG , "Credential raw response: " + accessToken .getRawResponse ());
422
-
425
+
423
426
resp .putString ("status" , "ok" );
424
427
resp .putBoolean ("authorized" , true );
425
428
resp .putString ("provider" , providerName );
426
- response .putString ("uuid" , accessToken .getParameter ("user_id" ));
429
+ String uuid = (String ) accessTokenMap .get ("user_id" );
430
+ response .putString ("uuid" , uuid );
427
431
428
- String tokenType = accessToken . getParameter ("token_type" );
432
+ String tokenType = ( String ) accessTokenMap . get ("token_type" );
429
433
if (tokenType == null ) {
430
434
tokenType = "Bearer" ;
431
435
}
@@ -453,24 +457,26 @@ private WritableMap accessTokenResponse(
453
457
) {
454
458
WritableMap resp = Arguments .createMap ();
455
459
WritableMap response = Arguments .createMap ();
460
+ Map accessTokenMap = new Gson ().fromJson (accessToken .getRawResponse (), Map .class );
456
461
457
462
resp .putString ("status" , "ok" );
458
463
resp .putBoolean ("authorized" , true );
459
464
resp .putString ("provider" , providerName );
460
465
try {
461
- response .putString ("uuid" , accessToken .getParameter ("user_id" ));
466
+ String uuid = (String ) accessTokenMap .get ("user_id" );
467
+ response .putString ("uuid" , uuid );
462
468
} catch (Exception ex ) {
463
469
Log .e (TAG , "Exception while getting the access token" );
464
470
ex .printStackTrace ();
465
471
}
466
472
467
473
WritableMap credentials = Arguments .createMap ();
468
474
Log .d (TAG , "Credential raw response: " + accessToken .getRawResponse ());
469
-
475
+
470
476
credentials .putString ("accessToken" , accessToken .getAccessToken ());
471
477
String authHeader ;
472
478
473
- String tokenType = accessToken . getParameter ("token_type" );
479
+ String tokenType = ( String ) accessTokenMap . get ("token_type" );
474
480
if (tokenType == null ) {
475
481
tokenType = "Bearer" ;
476
482
}
@@ -481,12 +487,14 @@ private WritableMap accessTokenResponse(
481
487
}
482
488
483
489
String clientID = (String ) cfg .get ("client_id" );
490
+ String idToken = (String ) accessTokenMap .get ("id_token" );
484
491
485
492
authHeader = tokenType + " " + accessToken .getAccessToken ();
486
493
credentials .putString ("authorizationHeader" , authHeader );
487
494
credentials .putString ("type" , tokenType );
488
495
credentials .putString ("scopes" , scope );
489
496
credentials .putString ("clientID" , clientID );
497
+ credentials .putString ("idToken" , idToken );
490
498
response .putMap ("credentials" , credentials );
491
499
492
500
resp .putMap ("response" , response );
@@ -570,4 +578,4 @@ public static List<Object> recursivelyDeconstructReadableArray(ReadableArray rea
570
578
}
571
579
return deconstructedList ;
572
580
}
573
- }
581
+ }
0 commit comments