我有一个网站,用户希望有他们的谷歌日历所有的例子似乎都有日历的所有者每次都进行身份验证。有没有办法验证我的应用程序以获取用户日历数据并显示它?
在他们接受我的应用程序后,我试图保存access_token
所有者的,但过了一会儿我收到以下错误:
The OAuth 2.0 access token has expired, and a refresh token is not available. Refresh tokens are not returned for responses that were auto-approved.
这是我正在尝试的代码(顺便说一句,config.php 填写了所有 api 内容)
$client = new Google_Client();
$client->setUseObjects(true);
$client->setApplicationName("My Unit Calendar");
$client->setAccessType('offline');
$client->setAccessToken($row['access_token'] ); //from the DB
$calService = new Google_CalendarService($client);
$events = $calService->events->listEvents( $row['google_cal_id'] ); //from the DB
echo "events--><pre>".print_r($events,true)."</pre>";
但我得到以下异常:
Google_AuthException-->The OAuth 2.0 access token has expired, and a refresh token is not available. Refresh tokens are not returned for responses that were auto-approved.
谢谢你的帮助