Home How to get app accesstoken for marketing API Facebook
Reply: 0

How to get app accesstoken for marketing API Facebook

NVO
1#
NVO Published in 2017-12-06 15:23:23Z

We want to use the Marketing API from Facebook. We have build an app which allows us to create ads. Now we want to make the app public, but we need an access token to grant access to the app. I can create an access_token from my app dashboard > Marketing API > Tools, but that key expires after some time (do not know the exact lifetime) so I need a way to get an fresh access token.

I tried to get the key using this request:

function refreshToken(callback){
    request.get({
        headers: { 'content-type': 'application/json' },
        url: 'https://graph.facebook.com/oauth/access_token?client_id=' + appId + '&client_secret=' + appSecret + '&grant_type=client_credentials',
        method: 'GET'
    }, function (error, response, body) {
        callback(null, JSON.parse(body));
    });
}

Which gives me APP_ID|ACCESS_TOKEN in the body.access_token.

{"data":{"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190,"fbtrace_id":"EhprtaKcDFj"}},"status":400,"config":{"method":"POST","transformResponse":[null],"jsonpCallbackParam":"callback","headers":{"Accept":"application/json, text/plain, /"},"url":"https://graph.facebook.com/v2.11/act_[my_advertiser_id]/adimages","data":{}},"statusText":""}

It looks like it isn't a valid access_token. When I compare that access_code with the one I get from the app dashboard, I see that the valid code (from the dashboard) is a quite longer than the code from the request.

How can I get a valid access_token to access the Marketing API functions?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298987 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO