Skip to content

Twitter Android Crash When Redirecting #142

Description

@hanalaydrus

This issue showed in version 2.2.0. Twitter work in version 2.1.16.
I have fill the login form, after that It was trying to redirect but turns out the app crash and exited.

screenshot_20170815-132825

screenshot_20170815-132828

I specified the callback url as http://localhost/twitter I also try to specify with other url but nothing work.

Activity

  1. changed the title [-]Twitter Android Crash When Redirected[/-] [+]Twitter Android Crash When Redirecting[/+] on Aug 15, 2017
  2. jslok commented on Aug 31, 2017

    @jslok

    @hanalaydrus Were you able to find a solution to this? I am running into this problem as well.

  3. f4z3k4s commented on Sep 4, 2017

    @f4z3k4s

    Same problem here.

  4. vvnull commented on Sep 5, 2017

    @vvnull

    Also having this issue. Worked briefly after #121, but since a reinstallation I have not been able to restore to a working configuration.

  5. f4z3k4s commented on Sep 5, 2017

    @f4z3k4s

    @VioVoid Temporarily you can make it work by starting on 2.2.0, applying the changes of #121, and changing the line I just mentioned at #121 to this: String oauthTokenSecret = (String) accessToken.getTokenSecret();

  6. SailingSteve commented on Oct 3, 2017

    @SailingSteve
    Contributor

    Gilnave's changes worked for me with one additional fix
    https://github.com/fullstackreact/react-native-oauth/pull/121/files

    In OAuthManagerModule.java at line 410, I replaced
    String oauthTokenSecret = (String) accessTokenMap.get("oauth_token_secret");
    with
    String oauthTokenSecret = (String) accessToken.getParameter("token_secret");

    then it worked.

  7. SailingSteve commented on Oct 25, 2017

    @SailingSteve
    Contributor

    After many other changes, I ran into another issue with version 2.2.2 , like in issue 165 where the Gson parsing throws unhandled exceptions. (My personal feeling is that the introduction of Gson parsing has not helped this project). Removing Gson parsing fixed the problem -- the redirect back to the app no longer crashed when I replaced accessTokenResponse() from 2.2.2 with the updated method that follows:

        final String providerName,
        final HashMap<String,Object> cfg,
        final OAuth1AccessToken accessToken,
        final String oauthVersion
      ) {
        WritableMap resp = Arguments.createMap();
        WritableMap response = Arguments.createMap();
    
        Log.d(TAG, "Credential raw response: " + accessToken.getRawResponse());
        
        resp.putString("status", "ok");
        resp.putBoolean("authorized", true);
        resp.putString("provider", providerName);
        String uuid = (String) accessToken.getParameter("user_id");
        response.putString("uuid", uuid);
        String oauthTokenSecret = (String) accessToken.getParameter("oauth_token_secret");
        
        String tokenType = (String) accessToken.getParameter("token_type");
        if (tokenType == null) {
          tokenType = "Bearer";
        }
    
        String consumerKey = (String) cfg.get("consumer_key");
    
        WritableMap credentials = Arguments.createMap();
        credentials.putString("access_token", accessToken.getToken());
        credentials.putString("access_token_secret", oauthTokenSecret);
        credentials.putString("type", tokenType);
        // credentials.putString("scope", accessToken.getScope());
        credentials.putString("consumerKey", consumerKey);
    
        response.putMap("credentials", credentials);
    
        resp.putMap("response", response);
    
        return resp;
      }
    

    In Version 2.2.2, when you surround the Gson parsing with a try/catch, it throws "com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $" for a twitter accessToken.getRawResponse() value of "oauth_token=8565211111111111111042-1111111111111111111111111111111111111qLhV&oauth_token_secret=BT1111111111111111111111111112EPq&user_id=8111111111111111111142&screen_name=StevePodell&x_auth_expires=0" (I obscured WeVote's private tokens in this example.)

  8. added a commit that references this issue on Jul 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions