Twitter Fabric Token and Secret Validation

android
fabric
oauth

#1

Thanks for reading.

I am writing an Android application built on the Fabric framework at the moment. I am having one small issue. When a user successfully authenticates with twitter, I store the token and the secret on their device in the SharedPreferences. This works great. The only issue I found is when I go into my twitter account and revoke access. I get past the initial login screen because my only check is whether or not that value is null in the SharedPreferences. Is there a function where I can validate the token and secret on the twitter network itself?

Thanks for reading and let me know if you need any more info.


#2

One could use the AccountService to verify the session. The following example is using Twitter 2.0.

Twitter.getApiClient(session).getAccountService().verifyCredentials(false, false).enqueue(new Callback<User>() {
    @Override
    public void success(Result<User> result) {
        // Verified
    }

    @Override
    public void failure(TwitterException exception) {
        // No longer valid
    }
});

#3

Hi, Eric. Sorry for the late response. I will try this out. Thanks


#4