Paul Budnik
Paul Budnik

Reputation: 151

How to attach access token to a google calendar API request

Several documents on authorizing Google APIs reference attaching an access token without giving an unambiguous example. The request I generate is:

https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?ya29.1.AADtN

I have deleted most of the access token in the above line. This token was obtained successfully with:

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

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

and

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

in php. The token was taken from a structure with json_decode on $client->getAccessToken();

I am not sure the problem is attaching the token but it is one thing I am concerned about. The result was "403 Forbidden". I would appreciate any suggestions.

Upvotes: 2

Views: 13464

Answers (1)

Paul Budnik
Paul Budnik

Reputation: 151

I found a site that almost gives an unambiguous example although it still took two trys to get it correctly. The site is https://developers.google.com/accounts/docs/OAuth2InstalledApp#callinganapi

The rule appears to be to append an access token add "?access_token=" followed by the token.

Upvotes: 3

Related Questions