1

I'm trying to set up Google Calendar API push notifications, but I don't know how to access the auth_token_for_current_user that I need in my POST request to the watch method. How do I access it?

I'm asking about the auth token part after the Bearer in the authorization header.

POST https://www.googleapis.com/calendar/v3/calendars/my_calendar@gmail.com/events/watch Authorization: Bearer auth_token_for_current_user

Content-Type: application/json

If it matters, my registered domain is a heroku instance. And I know how to retrieve calendar event info after going through the javascript quickstart tutorial.

lukkyjoe
  • 304
  • 4
  • 13
  • For testing purposes, get an auth token from the [OAuth Playground](https://developers.google.com/oauthplayground/) and enable the Calendar API. Exchange authorization code for access token. Use that for now and tell us how it goes. – ReyAnthonyRenacia Jun 22 '17 at 16:18
  • Refer to: https://stackoverflow.com/questions/28751995/how-to-obtain-google-service-account-access-token-javascript – Maha Oct 09 '17 at 14:58

1 Answers1

0

I'm working through Python, but maybe someone will still need it.

If you were also trying to access via this method: https://developers.google.com/calendar/api/quickstart/python Then my answer may help you.

Then after you successfully run the quickstart.py script, you will have a token.js file. "token" - is your auth_token_for_current_user. He is generated at every login with oAuth2. Correct me if I'm wrong somewhere. I am new to this topic

P.S. I'm not sure if you can get a token.json file on js either, but there's probably something similar there.

If you are trying to submit a request using OAuth 2.0 Playground , it will end up looking something like this:

POST /calendar/v3/https://www.googleapis.com/calendar/v3/calendars/my_calendar@gmail.com/events/watch/watch HTTP/1.1
Host: www.googleapis.com
Content-length: 110
Content-type: application/json
Authorization: Bearer auth_token_for_current_user
{
  "id": "AnythingCanBeEntered", 
  "type": "web_hook",
  "address": "https://mydomain_com/notifications",
}

my_calendar@gmail.com can be taken from your google calendar settings -> Calendar ID

Fedor
  • 1
  • 2