0

We have a live application that gives the "The API developer key is invalid" intermittently.

The normal flow:

  1. User clicks "Import from Google Drive"
  2. Gets an OAuth screen
  3. Selects a user (if there are more than one)
  4. Gets prompted with the Google Picker
  5. Picks a file
  6. File gets imported

But for some users, after selecting a user in point 3 (or automatically if there is only one user) the Picker dialog doesn't open, but gets prompted with an "In order to select an item from your online storage, please sign in" message on black background with red Sign in button on it. (see screenshot)

Sign in screen

Then after clicking "Sign in", the user receives the "The API developer key is invalid" error message, and the flow stops. (see screenshot again)

API key error screen

For the majority of the users everything works fine. Seems to be a per user issue, because we have an affected user that has multiple gmail addresses signed in into Chrome, and this issue happens with one email address, but doesn't happen with the other.

Any ideas?

bez
  • 11
  • 3
  • [Are the answers over here](https://stackoverflow.com/questions/22435410) of any help to you? – Rafa Guillermo Mar 31 '20 at 08:28
  • No, the API is clearly enabled (otherwise it would fail for everyone) and the callback looks exactly like the one in that example. But thanks! – bez Mar 31 '20 at 13:58
  • Does the auth flow for the app work in incognito mode for these users? – Rafa Guillermo Mar 31 '20 at 14:01
  • Yes, I got an affected user to test it. They can log in to the app via Google Auth, then when they try to do an import they are presented with the same dialog and the error. Not sure if it helps, but if I remove the setDeveloperKey() call from the client code, the api still works perfectly for those users that are not affected by the original bug, but those that are affected get a different error: "The feature you requested is currently unavailable" – bez Apr 01 '20 at 13:30
  • Does this still happen for the user when they only have *one* account logged in in Chrome? If so, can you re-obtain a new key from the project that has the API enabled and try with this? – Rafa Guillermo Apr 06 '20 at 13:12
  • Hi Rafa, thanks for the replies. Yes, it also happens when they only have one account logged in, and yes, I re-set the key and use the new one about 203 weeks ago. For your reference, the issue seems to be solved with a workaround, but I think this is a bug on Google's side. See solution and report here: https://github.com/google/google-api-javascript-client/issues/613 – bez Apr 07 '20 at 15:22

1 Answers1

1

After a long search, I found a workaround. I had to replace the gapi.auth2.init and gapi.auth2. signIn calls with gapi.auth2.authorize and it started to work for those affected users too. Submitted a report to Google about it, but at the time of writing, there was not much reply: https://github.com/google/google-api-javascript-client/issues/613

bez
  • 11
  • 3