Question: Android/Facebook Post To Page Error in Access Token

Question

Android/Facebook Post To Page Error in Access Token

Answers 0
Added at 2016-12-28 20:12
Tags
Question

im trying to post a message on a Facebook Page. The problem is that the access_token provided by the Graph API Explorer expires in just an hour. I tried to use this instead

Bundle params = new Bundle();
    params.putString("message", "f222222eed from android!!!!!!!");
    //params.putBoolean("published",true);
    AccessToken _token = AccessToken.getCurrentAccessToken();
    params.putString("access_token", _token.getToken());
    Log.e("Token App", _token.getToken());
    Log.e("Token App", _token.getExpires().toString());
    new GraphRequest(
            _token,
            "/[PAGE_ID]/feed",
            params,
            HttpMethod.POST,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    Log.e("Respuesta", response.toString());
                }
            }
    ).executeAsync();

But this returns an error

 {Response:  responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) Insufficient permission to post to target on behalf of the viewer}}

If i replace this line

params.putString("access_token", _token.getToken());

with an access_token from the Graph API, i get no errors but the expire time is just one hour.

I checked the results from both access tokens, the one i get from _token.getToken() and the one from the GRAPH API. These are the results

Token from _getToken

Identificador de la aplicación 1838452216426007 : YukoApp Metadata {"auth_type":"rerequest"} identificador de usuario 101457193689201 : Dn Zeravla El usuario instaló por última vez esta aplicación a través de la API v2.x Emitido(a) 1482914579 (hace 10 horas) Caducidad Nunca Válido Verdadero Origen Mobile Web Faceweb Ámbitos publish_pages, publish_actions, public_profile

Token from GRAPH API

Identificador de la aplicación 145634995501895 : Graph API Explorer identificador de usuario 110495982785322 : Dn Zeravla El usuario instaló por última vez esta aplicación a través de la API v2.x Emitido(a) Desconocido Caducidad 1482958800 (en una hora aproximadamente) Válido Verdadero Origen Web Ámbitos publish_pages, publish_actions, public_profile

I dont know why the _getToken one doesnt work and the Graph API does, pls help

Answers to

Android/Facebook Post To Page Error in Access Token

Source Show
◀ Wstecz