Abhishek
Abhishek

Reputation: 783

Facebook: Received Facebook error response of type OAuthException: Invalid OAuth access token. (code 190, subcode null)

Situation: I'm able to obtain an Access Token via a web-app, and also my profile name and profile ID. I added this code to post a message on my wall:

@SuppressWarnings("deprecation")
FacebookClient fbClient = new DefaultFacebookClient(accessToken, MY_APP_SECRET);
FacebookType publishMessageResponse =  fbClient.publish("me/feed", FacebookType.class,
        Parameter.with("message", "RestFB test 123"));

com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: Invalid OAuth access token. (code 190, subcode null)

Problem: I'm getting the error message:

Received Facebook error response of type OAuthException: Invalid OAuth access token. (code 190, subcode null)

What I've tried: I'm using restFb1.13 (Latest version). I tried with an older restFb1.7 too, but the error remains. I can't find the above error code in the documentation. Unfortunately, searching on StackOverflow and other sites does not list this error.

Any suggestions shall be very helpful.

Upvotes: 0

Views: 4084

Answers (1)

Abhishek
Abhishek

Reputation: 783

Solved it. The problem was that the Accesstoken received from facebook is of the format: AccessToken= some long alphanumeric string&expires=some string. We have to strip out the portion between "Accesstoken=" and "expires=".

I did it by

String accessToken;
accessToken = accessToken.substring(13,accessToken.lastIndexOf("&"));

Upvotes: 3

Related Questions