1

GAE에서 실행중인 PHP 애플리케이션이 있습니다. Google PHP 라이브러리 (v0.6.7)를 사용하여 Cloud Datastore에 연결합니다. 이 연결은 대부분 잘 작동하지만 때때로 OAuth2 토큰을 새로 고치려고 할 때 오류가 발생했음을 나타내는 다음 오류가 발생합니다.GAE - OAuth2 토큰 새로 고침 오류가 발생했습니다.

Error refreshing the OAuth2 token, message: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Google Accounts</title><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0" /> 

메시지는 또한 다음과 끝에 포함

You are not authorized to perform this request 

난이 접속 코드 이하 첨부. 보시다시피 Datastore 서비스에 자동으로 연결하기 위해 사용하고있는 P12 파일이 있습니다.

$account = '[email protected]'; 

$key = file_get_contents(dirname(__FILE__).'/../google-api-php-client/privatekey.p12'); 
    $client = new Google_Client(); 
    $client->setApplicationName($this->appId); 

    $client->setAssertionCredentials(
      new Google_AssertionCredentials(
        $account, 
        array('https://www.googleapis.com/auth/userinfo.email', 
          'https://www.googleapis.com/auth/datastore'), 
        $key) 
    ); 


    $datastore = new Google_DatastoreService($client); 

것은

나는 그것이 GAE 문제가 있거나이 오류를 반환 요청의 수를 줄이기 위해 노력 적어도이 문제를 해결하거나 내 코드에서 뭔가를 할 수 있는지 확실하지 오전입니다.

새 라이브러리 릴리스 (1.0.1-beta)가 있으며이 버전으로 마이그레이션 할 계획입니다. 그러나 이렇게하기 전에이 문제의 원인이 될 수있는 것에 대해 어떤 생각을 갖는 것이 매우 유용 할 것입니다.

답변

0

누군가가 유용하다고 생각할 때를 대비하여 직접 답변합니다.

일부 테스트를 수행 한 후에 연결 후 반환 된 토큰이 올바르게 저장되지 않았다는 것을 깨달았습니다. 결과적으로 시스템은 매 요청마다 토큰을 새로 고치려고했습니다. 분명히 주어진 요청 횟수가 지나면 Google은 해당 사용자의 토큰을 새로 고치려고하는 새로운 시도를 거부하고 위의 오류를 발생시킵니다.

관련 문제