Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
Expand Down Expand Up @@ -400,10 +401,27 @@ private WritableMap accessTokenResponse(
) {
WritableMap resp = Arguments.createMap();
WritableMap response = Arguments.createMap();
Map accessTokenMap = new Gson().fromJson(accessToken.getRawResponse(), Map.class);

Log.d(TAG, "Credential raw response: " + accessToken.getRawResponse());


/* Some things return as JSON, some as x-www-form-urlencoded (querystring) */

Map accessTokenMap = null;
try {
accessTokenMap = new Gson().fromJson(accessToken.getRawResponse(), Map.class);
} catch (JsonSyntaxException e) {
/*
failed to parse as JSON, so turn it into a HashMap which looks like the one we'd
get back from the JSON parser, so the rest of the code continues unchanged.
*/
Log.d(TAG, "Credential looks like a querystring; parsing as such");
accessTokenMap = new HashMap();
accessTokenMap.put("user_id", accessToken.getParameter("user_id"));
accessTokenMap.put("oauth_token_secret", accessToken.getParameter("oauth_token_secret"));
accessTokenMap.put("token_type", accessToken.getParameter("token_type"));
}


resp.putString("status", "ok");
resp.putBoolean("authorized", true);
resp.putString("provider", providerName);
Expand Down
3 changes: 2 additions & 1 deletion ios/OAuthManager/OAuthManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
NSMutableDictionary *cfg = [[manager getConfigForProvider:providerName] mutableCopy];

DCTAuthAccount *existingAccount = [manager accountForProvider:providerName];
NSString *clientID = ((DCTOAuth2Credential *) existingAccount).clientID;
NSString *clientID = ([providerName isEqualToString:@"google"]) ? ((DCTOAuth2Credential *) existingAccount).clientID : (NSString *)nil;

if (([providerName isEqualToString:@"google"] && existingAccount && clientID != nil)
|| (![providerName isEqualToString:@"google"] && existingAccount != nil)) {
if ([existingAccount isAuthorized]) {
Expand Down