如何将访问令牌附加到google日历API请求


How to attach access token to a google calendar API request

一些关于授权Google API的文档引用了附加访问令牌,但没有给出明确的示例。我生成的请求是:

https://www.googleapis.com/calendar/v3/calendars/mtnmath@mtnmath.com/events?ya29.1.AADtN

我已经删除了上面一行中的大部分访问令牌。此令牌已成功获得,使用:

$client->addScope("https://www.googleapis.com/auth/calendar");
$client->addScope("https://www.googleapis.com/auth/calendar.readonly");

$_SESSION['access_token'] = $client->getAccessToken();

在php中。令牌取自$client->getAccessToken(); 上具有json_decode的结构

我不确定问题是附加令牌,但这是我担心的一件事。结果是"403禁止"。如果有任何建议,我将不胜感激。

我发现一个网站几乎给出了一个明确的例子,尽管它仍然需要两次尝试才能正确获得。该网站https://developers.google.com/accounts/docs/OAuth2InstalledApp#callinganapi

规则似乎是附加一个访问令牌add";?access_token=";然后是令牌。