2012-01-30 2 views
5

나는 가끔이 오류를 얻을 :오류 검증 액세스 토큰

Fatal error: Uncaught Exception: 190: Error validating access token: This may be because the user logged out or may be due to a system error. thrown in ..base_facebook.php on line 1053

문제는 내가 어떤 경고도없이, 임의의 시간에 그것을 얻을 것입니다. 나는 그것을 보지 않고 수 주일 간 갈 수 있고, 갑자기 그것이 나타날 것이다. 해결책? 너는 그것을 밖으로 기다릴 수있다. 그것은 약 15 분 동안이 오류를 던지면 새로 고침을 할 수 있으며 계속해서 자신이 한 일을 계속할 수 있습니다.

내 질문은 이것이 내 문제인가요? 아니면 Facebook 문제입니까? 이것이 도움이된다면 페이스 북 연결 페이지입니다. 나는 연구를 수행하여 FQL 쿼리로 인해 발생할 수 있다는 것을 알아 냈습니다. 하지만 적어도 일관성이 없습니까? 완전히 무작위 인 것처럼 보입니다. 어쨌든 내 FQL 쿼리 어쨌든. How-To: Handle expired access tokens (링크가 깨진) 개발자 블로그 게시물 작성으로

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

있는 라인 Base_Facebook의 1,052에서 1,071 사이,

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; 

}

당신에게

+1

분명히 [Facebook bug] (https://developers.facebook.com/bugs/179301482177807)입니다. – brainondev

+1

나는이 오류를 추가하고 싶습니다. 사용자가 계정을 비활성화 한 경우에도이 오류가 발생합니다. – Chris

답변

10

감사

Access tokens for users can become invalid due to various reasons. In most cases, they can expire if it’s past the time specified by the expires field (by default access token have a 2 hour lifetime). What many developers do not realize is that an access token can also expire if a user changes her password, logs out or if she de-authorizes the app via the App Dashboard. It is very important that your apps handle such situations. If your access token expires, you need to reacquire a valid access token.

offline_access (사용자가 응용 프로그램과 연결되어 있지 않은 한) 만료되지 않는 토큰을 가져올 수 있기 전에이 사용 권한은 이제 더 이상 만료 시간이있는 access_token을 얻을 수있는 방법을 확인하려면 Deprecation of Offline Access Permission을 참조하십시오.

업데이트 : 페이스 북에서 원래의 블로그 포스트가 만료 된 토큰 처리에 대한 것을 참고 아무튼 '2012년 8월 페이스 북 PHP-SDK have added simple way of extending access_token의로

업데이트 2 (자세한 내용은 How to extend access token validity since offline_access deprecation 참조) 더 이상 존재하지 않는다. 세부 정보를 얻는 데 사용할 수있는 새로운 문서가 있습니다. https://developers.facebook.com/docs/facebook-login/access-tokens/#extending

+1

귀하의 모든 링크는'페이지를 찾을 수 없음 '을 제공합니다, 링크를 업데이트하십시오 –