6
6
import android .support .annotation .Nullable ;
7
7
import android .util .Log ;
8
8
9
+ import com .google .gson .Gson ;
10
+
9
11
import com .facebook .react .bridge .Arguments ;
10
12
import com .facebook .react .bridge .Callback ;
11
13
import com .facebook .react .bridge .ReactApplicationContext ;
@@ -398,15 +400,17 @@ private WritableMap accessTokenResponse(
398
400
) {
399
401
WritableMap resp = Arguments .createMap ();
400
402
WritableMap response = Arguments .createMap ();
403
+ Map accessTokenMap = new Gson ().fromJson (accessToken .getRawResponse (), Map .class );
401
404
402
405
Log .d (TAG , "Credential raw response: " + accessToken .getRawResponse ());
403
-
406
+
404
407
resp .putString ("status" , "ok" );
405
408
resp .putBoolean ("authorized" , true );
406
409
resp .putString ("provider" , providerName );
407
- response .putString ("uuid" , accessToken .getParameter ("user_id" ));
410
+ String uuid = (String ) accessTokenMap .get ("user_id" );
411
+ response .putString ("uuid" , uuid );
408
412
409
- String tokenType = accessToken . getParameter ("token_type" );
413
+ String tokenType = ( String ) accessTokenMap . get ("token_type" );
410
414
if (tokenType == null ) {
411
415
tokenType = "Bearer" ;
412
416
}
@@ -434,24 +438,26 @@ private WritableMap accessTokenResponse(
434
438
) {
435
439
WritableMap resp = Arguments .createMap ();
436
440
WritableMap response = Arguments .createMap ();
441
+ Map accessTokenMap = new Gson ().fromJson (accessToken .getRawResponse (), Map .class );
437
442
438
443
resp .putString ("status" , "ok" );
439
444
resp .putBoolean ("authorized" , true );
440
445
resp .putString ("provider" , providerName );
441
446
try {
442
- response .putString ("uuid" , accessToken .getParameter ("user_id" ));
447
+ String uuid = (String ) accessTokenMap .get ("user_id" );
448
+ response .putString ("uuid" , uuid );
443
449
} catch (Exception ex ) {
444
450
Log .e (TAG , "Exception while getting the access token" );
445
451
ex .printStackTrace ();
446
452
}
447
453
448
454
WritableMap credentials = Arguments .createMap ();
449
455
Log .d (TAG , "Credential raw response: " + accessToken .getRawResponse ());
450
-
456
+
451
457
credentials .putString ("accessToken" , accessToken .getAccessToken ());
452
458
String authHeader ;
453
459
454
- String tokenType = accessToken . getParameter ("token_type" );
460
+ String tokenType = ( String ) accessTokenMap . get ("token_type" );
455
461
if (tokenType == null ) {
456
462
tokenType = "Bearer" ;
457
463
}
@@ -462,12 +468,14 @@ private WritableMap accessTokenResponse(
462
468
}
463
469
464
470
String clientID = (String ) cfg .get ("client_id" );
471
+ String idToken = (String ) accessTokenMap .get ("id_token" );
465
472
466
473
authHeader = tokenType + " " + accessToken .getAccessToken ();
467
474
credentials .putString ("authorizationHeader" , authHeader );
468
475
credentials .putString ("type" , tokenType );
469
476
credentials .putString ("scopes" , scope );
470
477
credentials .putString ("clientID" , clientID );
478
+ credentials .putString ("idToken" , idToken );
471
479
response .putMap ("credentials" , credentials );
472
480
473
481
resp .putMap ("response" , response );
@@ -551,4 +559,4 @@ public static List<Object> recursivelyDeconstructReadableArray(ReadableArray rea
551
559
}
552
560
return deconstructedList ;
553
561
}
554
- }
562
+ }
0 commit comments