English 中文(简体)
Facebook OAuth 例外: 无法解密访问符号
原标题:Facebook OAuthException: The access token could not be decrypted

我有一个运行中的应用程序,

但最近一些用户报告消息未张贴,

日志显示

OAuthException: The access token could not be decrypted. 

即使用户重新审查了应用程序并重置了其访问标记,但例外情形仍然存在。

错误的根源是什么? 围绕错误开展工作的方法是什么?

问题回答

如果您在向 Facebook API 发送 HTTP 请求时收到以下错误消息 :

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

这意味着当您提出 HTTP 请求时, 您发送到 Facebook 的访问标记“ 强” 是有效的 。

如果您看到 < 坚固 > HTTP 响应头 您将会看到这样的字段 :

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.

您可以使用"https:// developmenters.facebook.com/tools/debug/access_token" rel=“noreferrer” >Access Token Debugger 来检查Facebook上使用的 OAuth 2. 0 访问标牌(手令)的有效性。

Facebook的标语正在增加, 不再限制为 255 个字符, 所以如果您使用变量或大小有限的数据库字段, 存储它们的方式可能会导致例外 。

该Facebook文件的最后一节对此作了具体说明:https://developers.facebook.com/docs/facebook-login/access-tokens

<强 > 大小

期望随着Facebook改变其存储内容和编码方式,所有类型访问标牌的大小都会随时间变化。 您可以期望它们会随着时间增长和缩小。 请使用一个不设特定最大尺寸的变量长度数据类型来存储访问标牌 。

对于在 SQL 中存储符号的示例, 您可以避免使用 VARCHAR 并使用 TEXT 或 BLOB

这可能是因为在数据库保存前有象征性的修饰。 或字段大小小于符号包件大小。 请在 { 可变} 表格中检查一次, 以获取正确和完整的符号 。

之所以如此, 是因为当我请求“我”(我猜想,

调试器响应 :

App ID: 
<ID> :   <app>
User ID: Unknown
Issued:  Unknown
Expires: 1339171200 (in about an hour)
Valid:   True
Origin:  Web
Scopes: 

为了解决问题, 而不是要求我, 我要求用户识别码的简介, 我直接从用户识别码获得。

此错误经常发生在访问标记长度不正确时。 验证该标记的格式 。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签