验证访问令牌时出错

验证访问令牌时出错

本文介绍了验证访问令牌时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶尔会收到此错误:

问题是我随机得到它,没有任何警告。我可以走几周没有看到它,然后突然间会出现。解决方案?你可以等一下它会抛出这个错误大约15分钟,那么你可以刷新,它将允许你继续你在做什么。



我的问题是,这是我的一个问题结束?还是Facebook这个问题?这是一个Facebook连接页面,如果这有帮助。我做了研究,发现它可能是由FQL查询引起的。但那至少不一定呢?看起来完全是随机的。这是我的FQL查询,以防万一。

  $ facebook-> api(array('method'=> fql.query','query'=>SELECT first_name,middle_name,last_name,email,affiliations FROM user WHERE uid =。$ user)); 

这是Base_Facebook的第1052-1071行,

  protected function throwAPIException($ result){
$ e = new FacebookApiException($ result);
开关($ e-> getType()){
// OAuth 2.0 Draft 00 style
case'OAuthException':
// OAuth 2.0 Draft 10 style
case'invalid_token':
// REST服务器错误只是例外
case'异常':
$ message = $ e-> getMessage();
如果(($ message,'验证访问令牌的错误')!== false)||
(struts($ message,'Invalid OAuth access token')!== false)){
$ this-> setAccessToken(null);
$ this-> user = 0;
$ this-> clearAllPersistentData();
}
}

throw $ e;

}



谢谢

解决方案

如(链接已损坏)开发者博客文章

在我们可以使用 offline_access 获取不过期的令牌的权限(除非用户与应用程序连接),此权限现在已被弃用,请参阅,以了解如何获得 access_token 更长的到期时间。 / p>

更新:

截至2012年8月Facebook PHP-SDK (参见重新细节)



更新2:
请注意,Facebook上关于过期令牌处理的原始博客文章不再存在。有新的文件,可以用来获取细节。


I get this error occasionally:

The issue is that I get it at random times, without any warning. I can go weeks without seeing it, then all of a sudden it will come up. The solution? You can wait it out. It throws this error for about 15 minutes then you can refresh and it will allow you to continue with what you were doing.

My question is, is this an issue on my end? Or is this a Facebook issue? This is a Facebook connect page if that helps. I did research and found out it could be caused from the FQL query. But then wouldn't it be consistent at least? It seems like it is completely random. Here is my FQL query anyway just in case.

$facebook->api(array('method' => 'fql.query','query' => "SELECT first_name,middle_name,last_name,email,affiliations FROM user WHERE uid=".$user));

Here are lines 1052-1071 of Base_Facebook,

protected function throwAPIException($result) {
$e = new FacebookApiException($result);
switch ($e->getType()) {
  // OAuth 2.0 Draft 00 style
  case 'OAuthException':
    // OAuth 2.0 Draft 10 style
  case 'invalid_token':
    // REST server errors are just Exceptions
  case 'Exception':
    $message = $e->getMessage();
  if ((strpos($message, 'Error validating access token') !== false) ||
      (strpos($message, 'Invalid OAuth access token') !== false)) {
    $this->setAccessToken(null);
    $this->user = 0;
    $this->clearAllPersistentData();
  }
}

throw $e;

}

Thank you

解决方案

As written in (link is broken) developers blog post

Before we could use offline_access permission to get token that not expire (unless user is connected with application), this permission is now deprecated, see Deprecation of Offline Access Permission to see how you can get access_token with longer expiration time.

Update:
As of Aug 2012 Facebook PHP-SDK have added simple way of extending access_token (see How to extend access token validity since offline_access deprecation for more details)

Update 2:Note that original blog-post from Facebook about expired tokens handling doesn't exists anymore. There is new documentation hewever that may be used to get the details.https://developers.facebook.com/docs/facebook-login/access-tokens/#extending

这篇关于验证访问令牌时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:01