Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook OAuthException: The access token could not be decrypted

I have a running application that does scheduled wall posts to one of their friends on behalf of the user.

The application was running fine for quite some time but recently quiet a few of the users have reported the messages not being posted.

The logs shows

OAuthException: The access token could not be decrypted. 

Even if the user revisits the application and resets their Access token the exception persists.

What may be the root of the error and ways to work around it?

like image 829
rahul1810 Avatar asked May 24 '12 17:05

rahul1810


People also ask

What does OAuthException mean on Facebook?

OAuthException: If you receive an OAuthException error, it means that Edgar doesn't have the correct permissions to access your Facebook accounts right now. The password may have been changed on Facebook or Facebook may have reset your security session.

How do I fix an invalid access token for Facebook?

Facebook Error: Error Validating Access Token: The User Is Enrolled In A Blocking, Logged-in Checkpoint. If you've received this error, it means that your Facebook user account has failed a security checkpoint and you need to log in at https://www.facebook.com or https://m.facebook.com to correct the issue.

How do I fix an invalid access token?

There are two ways to fix the error: (RECOMMENDED) Change the application signature algorithm to RS256 instead of HS256. Change the value of your responseType parameter to token id_token (instead of the default), so that you receive an access token in the response.


1 Answers

If you get the following error message when making HTTP requests to the Facebook API:

{
  "error": {
       "message": "The access token could not be decrypted",
       "type": "OAuthException",
       "code": 190
  }
}

it means that the access token you are sending to Facebook when you make the HTTP request is NOT valid.

If you look at the HTTP response headers you will see a field like this:

WWW-Authenticate:OAuth "Facebook Platform" "invalid_token" "The access token could not be decrypted"

I was receiving the error above because I was sending an access token that was 1 character shorter than what was the valid one.
After comparing the access token persisted with the one I was sending I discovered this mistake.

You can check the validity of the OAuth 2.0 access token (bearer token) used on Facebook with the Access Token Debugger.

like image 110
Alex Bitek Avatar answered Sep 21 '22 07:09

Alex Bitek