Is it possible to decrypt Facebook’s new OAuth 2.0 access_token ?
I need to somehow get user_id and app_id from the access_token.
PS:
I need to get the user_id and app_id ONLY from the access_token as Facebook Linter used to do.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As others have already pointed out, the
access_tokenis a unique random string, so it cannot be decrypted as such. Also, we all know that theuser_idandapp_idare prerequesites to generate the token in the first place.However, let’s assume you stored your token(s) in a database and lost the associated
user_idandapp_id. In that case, it is a valid question on how to retrieve them having only the token at hand. If your token is still valid, this is possible. If it is expired, you’re out of luck.To retrieve the
user_id, make a call to:To retrieve the
app_id, make a call to:In both cases, the associated id’s will be part of the JSON response, regardless of the
access_tokenbeing an encrypted or unencrypted one.Let’s illustrate this with an example. Let’s assume Mark Zuckerberg uses the Graph API Explorer to generate an
access_token. Calling the/meendpoint gives you:and calling the
/appendpoint gives you:The ids you were looking for are part of the response.
Please note that this does not work with the
access_tokenshown on https://developers.facebook.com/apps (not sure if this is a Facebook mistake or intentional). Please use theaccess_tokenthat your app receives via OAuth.