Wednesday 18 July 2018

Twitter Login does not work if Twitter app is not installed in device

This may be the most asked question on SO, but i am still unable to fix my problem. I have checked this, this and many others, but the problem is still there.

If twitter app is installed on user's device, everything works fine, but if its not there i get the following error message.

Invalid json: Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

com.twitter.sdk.android.core.TwitterApiException: HTTP request failed, Status: 403 at com.twitter.sdk.android.core.Callback.onResponse(Callback.java:42)

I defined https://www.google.com as a callback URL, and following is my implementation.

//Activity Class

 Twitter.initialize(this);

 button.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {

                TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
                TwitterAuthToken authToken = session.getAuthToken();
                String token = authToken.token;
                String secret = authToken.secret;

                login(session);

            }

            @Override
            public void failure(TwitterException exception) {
                Log.d("Failure", "failure");
            }
        });

Strings.xml

   <string name="com.twitter.sdk.android.CONSUMER_KEY">---</string>
   <string name="com.twitter.sdk.android.CONSUMER_SECRET">---</string>

Gradle

compile 'com.twitter.sdk.android:twitter:3.1.1'

EDIT

I have also tried twittersdk:// and twitterkit-consumer-key:// as callback Url



from Twitter Login does not work if Twitter app is not installed in device

No comments:

Post a Comment