[GoogleAPI][v2][PHP] Google_Client OAuth Token Refresh (getrefreshtoken return null) – 更新Token
情境 PHP SDK文件與範例Code目前版本就是有坑:例如Calendar PHP Google Client OAuth Token就是無法Refresh,調用Method出來就是NULL。 $client->getRefreshToken(); // Output = NULL 解決方法 設定Google_Client時ApprovalPrompt要設為Froce… $client->setApprovalPrompt(‘force’); 修正後的PHP SDK範例: $client = new Google_Client(); $client->setApplicationName(APPLICATION_NAME); $client->setScopes(SCOPES); $client->setAuthConfig(CLIENT_SECRET_PATH); $client->setAccessType(‘offline’); $client->setApprovalPrompt(‘force’); 可以參考2011年文章:Upcoming changes to OAuth 2.0 endpoint