FB error:Expected 1 '.' in the input between the postcard and the payload

Talik picture Talik · Dec 7, 2011 · Viewed 7.7k times · Source

I have finished my app and then tried it on 3 FB accounts and it was ok, but the 4th have a permanent error (it cannot get an access token):

com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: Expected 1 '.' In the input between the postcard and the payload.

I tried to remove the app and install it again on this account a few times and nothing changed.

I use Java and restFB client.

This is the code where i get the access token:

if (request.getParameter("code") != null) {
    String code = request.getParameter("code");
    String url = "https://graph.facebook.com/oauth/access_token?"
        + "client_id=" + clientId + "&" + "client_secret="
        + clientSecret + "&" + "code=" + code + "&" + "redirect_uri="
        + redirectURL +"&type=web_server";
    String accessToken=readUrl(url).split("&")[0].replaceFirst("access_token=", "");
    //....
}

I saw here someone with the same error, he said that the solution was:

replacing "|" with "%257C" which made my access token invalid"

I couldn't really understand what he means.

Answer

Richard Barnett picture Richard Barnett · Feb 17, 2012

It's probably worth logging the response to the /oauth/access_token request and the value you extract for use as the access token.

For the account that doesn't work, check whether the /oauth/access_token response includes other parameters before access_token. IIRC I've seen responses like

expiry=86400&access_token=AAAxxxx