diff --git a/android/build.gradle b/android/build.gradle index b9ff010..18ac8b7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'maven' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "25.0.1" defaultConfig { minSdkVersion 16 diff --git a/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java b/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java index 35777a4..a8ee1a3 100644 --- a/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java +++ b/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java @@ -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; @@ -400,9 +401,25 @@ 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); diff --git a/ios/OAuthManager/OAuthManager.h b/ios/OAuthManager/OAuthManager.h index 4f653e4..7a2d783 100644 --- a/ios/OAuthManager/OAuthManager.h +++ b/ios/OAuthManager/OAuthManager.h @@ -7,10 +7,10 @@ #import -#if __has_include("RCTBridgeModule.h") - #import "RCTBridgeModule.h" +#if __has_include() + #import #else - #import + #import "RCTBridgeModule.h" #endif #if __has_include("RCTLinkingManager.h")