简体   繁体   中英

How to get extended user access token of marketing API using restfb

I have tried getting extended user access token, but this user with following code

AccessToken accessToken =
               new DefaultFacebookClient().obtainExtendedAccessToken(MY_APP_ID,
                 MY_APP_SECRET, MY_ACCESS_TOKEN);

this access token is having permission for only public profiles, I need an user access token with permission to ads_management ads_read and I am getting Exception while trying to get adaccounts:

{  
    "error":{  
        "message":"(#10) You do not have sufficient permissions to perform this action",  
        "type":"OAuthException",  
        "code":10,  
        "fbtrace_id":"GG27ChsELJV"  
    }   
}

We are able to fetch user access token which provides ads_read access by default, if we get MY_ACCESS_TOKEN from admin(page admin). AccessToken accessToken = new DefaultFacebookClient().obtainExtendedAccessToken(MY_APP_ID, MY_APP_SECRET, MY_ACCESS_TOKEN);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM