|
7 | 7 | import android.util.Log;
|
8 | 8 |
|
9 | 9 | import com.google.gson.Gson;
|
| 10 | +import com.google.gson.JsonSyntaxException; |
10 | 11 |
|
11 | 12 | import com.facebook.react.bridge.Arguments;
|
12 | 13 | import com.facebook.react.bridge.Callback;
|
@@ -403,7 +404,25 @@ private WritableMap accessTokenResponse(
|
403 | 404 | Map accessTokenMap = new Gson().fromJson(accessToken.getRawResponse(), Map.class);
|
404 | 405 |
|
405 | 406 | Log.d(TAG, "Credential raw response: " + accessToken.getRawResponse());
|
406 |
| - |
| 407 | + |
| 408 | + /* Some things return as JSON, some as x-www-form-urlencoded (querystring) */ |
| 409 | + |
| 410 | + Map accessTokenMap = null; |
| 411 | + try { |
| 412 | + accessTokenMap = new Gson().fromJson(accessToken.getRawResponse(), Map.class); |
| 413 | + } catch (JsonSyntaxException e) { |
| 414 | + /* |
| 415 | + failed to parse as JSON, so turn it into a HashMap which looks like the one we'd |
| 416 | + get back from the JSON parser, so the rest of the code continues unchanged. |
| 417 | + */ |
| 418 | + Log.d(TAG, "Credential looks like a querystring; parsing as such"); |
| 419 | + accessTokenMap = new HashMap(); |
| 420 | + accessTokenMap.put("user_id", accessToken.getParameter("user_id")); |
| 421 | + accessTokenMap.put("oauth_token_secret", accessToken.getParameter("oauth_token_secret")); |
| 422 | + accessTokenMap.put("token_type", accessToken.getParameter("token_type")); |
| 423 | + } |
| 424 | + |
| 425 | + |
407 | 426 | resp.putString("status", "ok");
|
408 | 427 | resp.putBoolean("authorized", true);
|
409 | 428 | resp.putString("provider", providerName);
|
|
0 commit comments