refreshTokenWithAssertion Permission Denied

家住魔仙堡 提交于 2019-12-04 10:12:35

Hi John I´ve the same problem and finally this works for me:

Before the lines:

if($client->getAuth()->isAccessTokenExpired()) {
  $client->getAuth()->refreshTokenWithAssertion(); //<<<<<failed here.
} 

I put a try catch and that returns me that I had a writtin permissions problem:

try {
  $client->getAuth()->refreshTokenWithAssertion($cred);
} catch (Exception $e) {
  var_dump($e->getMessage());
}

I could do 2 things:

1) Go to Google/src/Config.php and change line 94: 'directory' => sys_get_temp_dir() . '/Google_Client'and change the directory to save cache temp files

2) or like me, made a echo sys_get_temp_dir(); before the try catch and give a chmod 777 permission to that dir

This solution works for me, I hope also for you. Anyway made an try/catch waiting for the exception message

See the service-account.php sample in the examples/ directory of the Google APIs Client Library for PHP on Github.com:

if($client->getAuth()->isAccessTokenExpired()) {
  $client->getAuth()->refreshTokenWithAssertion($cred); // set credentials there
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!