Search code examples
facebookaccess-token

App Access Token can't retrieve Test Users?


I can't get the list of my test users with my app access token. First I get the app access token with the following graph api call:

    https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials

which succeeds, I get an access token in the format

    APP_ID|SomeRandomCharacters

Now I try to get my list of test-users using the following graph API call:

    https://graph.facebook.com/APP_ID/accounts/test-users?access_token=APP_ACCESS_TOKEN

however, I get a "bad URL" error in my iOS code.

If I try to go to that address directly in a browser I get HTTP 400 Bad Request and if I try it in the Graph API explorer, I get

    {  "error": 
        {    "message": "An access token is required to request this resource.",     
             "type": "OAuthException",     
             "code": 104  
        }
    }

Solution

  • Check your app isn't defined as 'Desktop/Native' - if it is, your app secret is considered untrusted for API calls that can change the app's settings (including Test Users)

    The assumption is that the app secret has been distributed with your native app and can't be trusted.