browser-samples icon indicating copy to clipboard operation
browser-samples copied to clipboard

Calendar API quickstart requests whitelisted domain

Open aknoefel opened this issue 4 years ago • 2 comments

Expected Behavior

I followed all steps in the example https://developers.google.com/calendar/quickstart/js

  1. Setup a new project via the button
  2. Setup a new API key via the button
  3. copied and pasted the code to a page on my web site /googleCal.html

Now I expect to see the Google Oauth authorization screen to grant access to my calendar

Actual Behavior

{ "error": "idpiframe_initialization_failed", "details": "Not a valid origin for the client: https:// has not been whitelisted for client ID XXXX-YYYY.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID." }

I tried without success all combinations of below: a) restricting the application to web browsers and added "https://mydomain/*" as the URL restriction b) restricting the API to calendar only

All info I find about whitelisting points to an Oauth client, which generates a client Id and secret, not the requested client ID and API key.

I tried adding an Oauth client with the correct whitelisted website, even though this is not part of the example and "mix and match": The API key from the "API KEYS" section, and the Oauth client ID from the "OAuth 2.0 Client IDs" section. The Oauth client lists the required domain in it's callback URI.

Now the error seemingly goes away, but I get the error below in the console, on the call gapi.client.calendar.events.list ....

Bottom line, the example is somehow incomplete and does not work.

JavaScript Console Output

Uncaught TypeError: Cannot read property 'events' of undefined at googleCal.html:137 at e.Br (cb=gapi.loaded_0:239) at $k (cb=gapi.loaded_0:242) at Vk (cb=gapi.loaded_0:242) at _.Gk.cT (cb=gapi.loaded_0:242) at Fk (cb=gapi.loaded_0:234)

(View your JavaScript Console to see if there are any errors)

Specifications

  • Browser (Chrome/Internet Explorer/Firefox):
  • OS (Mac/Linux/Windows):

aknoefel avatar Dec 11 '20 00:12 aknoefel

The same thing happens with Gmail API also! https://developers.google.com/gmail/api/quickstart/js I have followed this docs.

Abhishek01039 avatar Dec 17 '20 09:12 Abhishek01039

having this same issue bump

ub3rb3457 avatar Dec 08 '21 02:12 ub3rb3457

Quickstarts + instructions were recently updated to address auth issues. Marking as closed.

sqrrrl avatar Oct 03 '22 19:10 sqrrrl