@@ -126,7 +126,7 @@ public void authorize(
126
126
{
127
127
try {
128
128
final OAuthManagerModule self = this ;
129
- HashMap <String ,Object > cfg = this .getConfiguration (providerName );
129
+ final HashMap <String ,Object > cfg = this .getConfiguration (providerName );
130
130
final String authVersion = (String ) cfg .get ("auth_version" );
131
131
Activity activity = mReactContext .getCurrentActivity ();
132
132
FragmentManager fragmentManager = activity .getFragmentManager ();
@@ -141,14 +141,14 @@ public void onOAuth1AccessToken(final OAuth1AccessToken accessToken) {
141
141
_credentialsStore .store (providerName , accessToken );
142
142
_credentialsStore .commit ();
143
143
144
- WritableMap resp = self .accessTokenResponse (providerName , accessToken , authVersion );
144
+ WritableMap resp = self .accessTokenResponse (providerName , cfg , accessToken , authVersion );
145
145
callback .invoke (null , resp );
146
146
}
147
147
public void onOAuth2AccessToken (final OAuth2AccessToken accessToken ) {
148
148
_credentialsStore .store (providerName , accessToken );
149
149
_credentialsStore .commit ();
150
150
151
- WritableMap resp = self .accessTokenResponse (providerName , accessToken , authVersion );
151
+ WritableMap resp = self .accessTokenResponse (providerName , cfg , accessToken , authVersion );
152
152
callback .invoke (null , resp );
153
153
}
154
154
};
@@ -364,15 +364,15 @@ public void getSavedAccount(
364
364
throw new Exception ("No token found" );
365
365
}
366
366
367
- WritableMap resp = this .accessTokenResponse (providerName , token , authVersion );
367
+ WritableMap resp = this .accessTokenResponse (providerName , cfg , token , authVersion );
368
368
onComplete .invoke (null , resp );
369
369
} else if (authVersion .equals ("2.0" )) {
370
370
OAuth2AccessToken token = _credentialsStore .get (providerName , OAuth2AccessToken .class );
371
371
372
372
if (token == null || token .equals ("" )) {
373
373
throw new Exception ("No token found" );
374
374
}
375
- WritableMap resp = this .accessTokenResponse (providerName , token , authVersion );
375
+ WritableMap resp = this .accessTokenResponse (providerName , cfg , token , authVersion );
376
376
onComplete .invoke (null , resp );
377
377
} else {
378
378
@@ -420,19 +420,33 @@ private HashMap<String,Object> getConfiguration(
420
420
421
421
private WritableMap accessTokenResponse (
422
422
final String providerName ,
423
+ final HashMap <String ,Object > cfg ,
423
424
final OAuth1AccessToken accessToken ,
424
425
final String oauthVersion
425
426
) {
426
427
WritableMap resp = Arguments .createMap ();
427
428
WritableMap response = Arguments .createMap ();
428
429
430
+ Log .d (TAG , "Credential raw response: " + accessToken .getRawResponse ());
431
+
429
432
resp .putString ("status" , "ok" );
433
+ resp .putBoolean ("authorized" , true );
430
434
resp .putString ("provider" , providerName );
431
435
response .putString ("uuid" , accessToken .getParameter ("user_id" ));
432
436
437
+ String tokenType = accessToken .getParameter ("token_type" );
438
+ if (tokenType == null ) {
439
+ tokenType = "Bearer" ;
440
+ }
441
+
442
+ String consumerKey = (String ) cfg .get ("consumer_key" );
443
+
433
444
WritableMap credentials = Arguments .createMap ();
434
- credentials .putString ("oauth_token" , accessToken .getToken ());
435
- credentials .putString ("oauth_secret" , accessToken .getTokenSecret ());
445
+ credentials .putString ("accessToken" , accessToken .getToken ());
446
+ credentials .putString ("type" , tokenType );
447
+ // credentials.putString("scope", accessToken.getScope());
448
+ credentials .putString ("consumerKey" , consumerKey );
449
+
436
450
response .putMap ("credentials" , credentials );
437
451
438
452
resp .putMap ("response" , response );
@@ -442,13 +456,15 @@ private WritableMap accessTokenResponse(
442
456
443
457
private WritableMap accessTokenResponse (
444
458
final String providerName ,
459
+ final HashMap <String ,Object > cfg ,
445
460
final OAuth2AccessToken accessToken ,
446
461
final String oauthVersion
447
462
) {
448
463
WritableMap resp = Arguments .createMap ();
449
464
WritableMap response = Arguments .createMap ();
450
465
451
466
resp .putString ("status" , "ok" );
467
+ resp .putBoolean ("authorized" , true );
452
468
resp .putString ("provider" , providerName );
453
469
try {
454
470
response .putString ("uuid" , accessToken .getParameter ("user_id" ));
@@ -458,9 +474,27 @@ private WritableMap accessTokenResponse(
458
474
}
459
475
460
476
WritableMap credentials = Arguments .createMap ();
461
- credentials .putString ("oauth_token" , accessToken .getAccessToken ());
462
- credentials .putString ("oauth_secret" , "" );
463
- credentials .putString ("scope" , accessToken .getScope ());
477
+ Log .d (TAG , "Credential raw response: " + accessToken .getRawResponse ());
478
+
479
+ credentials .putString ("accessToken" , accessToken .getAccessToken ());
480
+ String authHeader ;
481
+
482
+ String tokenType = accessToken .getParameter ("token_type" );
483
+ if (tokenType == null ) {
484
+ tokenType = "Bearer" ;
485
+ }
486
+ String scope = accessToken .getScope ();
487
+ if (scope == null ) {
488
+ scope = (String ) cfg .get ("scopes" );
489
+ }
490
+
491
+ String clientID = (String ) cfg .get ("client_id" );
492
+
493
+ authHeader = tokenType + " " + accessToken .getAccessToken ();
494
+ credentials .putString ("authorizationHeader" , authHeader );
495
+ credentials .putString ("type" , tokenType );
496
+ credentials .putString ("scope" , scope );
497
+ credentials .putString ("clientID" , clientID );
464
498
response .putMap ("credentials" , credentials );
465
499
466
500
resp .putMap ("response" , response );
0 commit comments