Immo
Immo

Reputation: 601

Extract app_id and user_id from Facebook Access Token

I have the following access token:

161551960578281|2.AQDCjxLBWAwdLle6.3600.1311602400.0-544419103231|0L0tcyKgGA0WT3SPJ29CVXqChwk

From this access_token:

App_id = 161551960578281

and

User_id = 544419103231

Can someone provide an example on how to get those programmaticaly using Ruby / RoR.

EDIT:

Do not care if they will change the format in the future!

Upvotes: 1

Views: 1420

Answers (1)

Igy
Igy

Reputation: 43816

You can't rely on that format being constant, you should use the access token linter at https://developers.facebook.com/tools/access_token/lint which will give you both fields.

Programmatically, you can determine the user ID via a graph API call: https://graph.facebook.com/me?fields=id&access_token=[ACCESS TOKEN HERE] - if the token is still valid you'll get back an answer like this:

{         
"id": "[UID HERE]"
}

I'm not sure of a good way to determine the app ID via an API call, but you should already have this since it's your app.

Upvotes: 3

Related Questions