parse-community / ParseUI-Android

ParseUI contains user interface libraries for building apps with the Parse Android SDK.
Other
592 stars 323 forks source link

Twitter login not working? #83

Closed Orbyt closed 8 years ago

Orbyt commented 8 years ago

Is the twitter login not working for anyone else? Im using a ParseLoginDispatchActivity to protect an Activity behind a sign-up wall if theres no logged in user.

I have TWITTER_LOGIN_ENABLED set to true in my Manifest via:

<meta-data
                android:name="com.parse.ui.ParseLoginActivity.TWITTER_LOGIN_ENABLED"
                android:value="true"/>

Upon the sign-up activity being launched and then clicking on the "Log in with Twitter" button, I get a "Twitter login failed" Toast message, and after a few tries I get:

Leak found
    java.lang.IllegalStateException: AndroidHttpClient created and never closed
            at android.net.http.AndroidHttpClient.<init>(AndroidHttpClient.java:156)

Anyone else having this issue? Any ideas on a solution?

wangmengyan95 commented 8 years ago

Hi @Orbyt, this is actually a bug in our ParseTwitterUtils, check this issue.

Orbyt commented 8 years ago

@wangmengyan95 Would this still cause the login to fail though?

wangmengyan95 commented 8 years ago

Hi @Orbyt, I test the sample app in my emulator and device. It works fine. So in your case, could you provide the following information

  1. Your test environment
  2. The way you use ParseLoginDispatchActivity BTW, we open source ParseTwitterUtil recently. So could you update to the latest library and try again?
Orbyt commented 8 years ago

@wangmengyan95

AS 1.3.2 on a Nexus 5 running Lollipop. These are all Parse related gradle dependencies im using:

compile 'com.parse:parse-android:1.10.3'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parsetwitterutils-android:1.10.3'
    compile project(':ParseUI-Login')
    compile project(':ParseUI-Widget')

For the dispatchactivity, I simply have a button that launches the protected activity. On button click, im doing:

Intent intent = new Intent(getContext(), AddDispatchActivity.class);
                startActivity(intent);

and the dispatchActivity:

public class AddDispatchActivity extends ParseLoginDispatchActivity {
    @Override
    protected Class<?> getTargetClass() {
        return AddActivity.class;
    }
}

This works fine if I signup using email/password, but again, the Twitter login just gives me a "Twitter login failed" Toast message.

I just downloaded and tried the ParseLoginSampleWithDispatchActivity sample app, and I got the same error when trying to login with twitter. With this sample though, I wasnt able to login with email/password either.

EDIT:

So found this line in ParseLoginFragment:

if (e != null) {
                showToast(R.string.com_parse_ui_twitter_login_failed_toast);
                debugLog(getString(R.string.com_parse_ui_login_warning_twitter_login_failed) +
                    e.toString());
              }

So heres the ParseException being thrown:

Twitter login failed, exception: com.parse.ParseException: com.parse.internal.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.

grantland commented 8 years ago

Could you verify that your device's clock is correct?

Orbyt commented 8 years ago

Hmm well I just noticed that my home clock on my Nexus 5 is about 30 seconds ahead of the time on my computer. Strange. Is this part of the issue? Wonder which one is correct haha.

EDIT: Noticed my tablet is about 45 seconds ahead of my computer.

grantland commented 8 years ago

OAuth requests use the current time to sign/validate requests so it is possible, especially since it looks like the error you're receiving is regarding the signature not matching.

It might be worthwhile to double check the date on your device as well.

Orbyt commented 8 years ago

Mmk so I was able to get the Twitter sign in working for my application. Guess it was just an issue with the Callback URL specified when setting up a Twitter app. Not entirely sure what its supposed to be for an android app but any valid URL seems to work.

Logging in via with the sample apps still gives the same errors, not sure how they're set up with twitters API but perhaps thats the issue?

grantland commented 8 years ago

Yup this is outlined in our guide: https://parse.com/docs/android/guide#users-twitter-users

When asked to specify a "Callback URL" for your Twitter app, please insert a valid URL. This value will not be used by your iOS or Android application, but is necessary in order to enable authentication through Twitter.

Orbyt commented 8 years ago

@grantland Yea thanks. Is there a recommended URL to use?

Any idea why the sample apps are throwing these errors?

grantland commented 8 years ago

Yea thanks. Is there a recommended URL to use?

If you're just using it for Android/iOS anything really.

Any idea why the sample apps are throwing these errors?

@wangmengyan95 will be able to help with that.

parse-github-bot commented 8 years ago

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

parse-github-bot commented 8 years ago

We are closing this issue due to another 7 days of inactivity. If you have additional information to help pinpoint this issue as an SDK bug, please reopen it with the additional information.Thank you for your feedback.