首页 > 解决方案 > Intermittent "The API developer key is invalid" error

问题描述

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?

标签: google-apigoogle-drive-apigoogle-picker

解决方案


经过长时间的搜索,我找到了解决方法。我不得不替换gapi.auth2.initandgapi.auth2. signIn调用,gapi.auth2.authorize它也开始为那些受影响的用户工作。向谷歌提交了一份关于它的报告,但在撰写本文时,没有太多回复:https ://github.com/google/google-api-javascript-client/issues/613


推荐阅读