Google API authentication: Not valid origin for the client

前端 未结 11 1550
暖寄归人
暖寄归人 2020-12-08 13:01

When making an auth request to the Google API (gapi), it\'s returning false on the checkOrigin.

I have removed any client id\'s or anything that would link directly

相关标签:
11条回答
  • 2020-12-08 13:32

    For me - I just went here:

    https://console.developers.google.com/apis/credentials

    Then chose the right project; then choose the credential with the same ID shown in your console error message. When editing the credentials you can add multiple origins to the white list.

    0 讨论(0)
  • 2020-12-08 13:40

    clearing the cache works for me.

    for React developers try to restart the project otherwise it will show the same error again and again.

    0 讨论(0)
  • I received the same console error message when working with this example: https://developers.google.com/analytics/devguides/reporting/embed/v1/getting-started

    The documentation says not to overlook two critical steps ("As you go through the instructions, it's important that you not overlook these two critical steps: Enable the Analytics API [&] Set the correct origins"), but does not clearly state WHERE to set the correct origins.

    Since the client ID I had was not working, I created a new project and a new client ID. The new project may not have been necessary, but I'm retaining (and using) it.

    Here's what worked:

    • Create a new project
    • Add and Enable the Analytics API
    • Create a new credential - ensure that it is an OAUTH credential (scroll to the bottom of this page for instructions https://developers.google.com/api-client-library/javascript/start/start-js#Setup).

    During creation of the credentials, you will see a section called "Restrictions Enter JavaScript origins, redirect URIs, or both". This is where you can enter your origins.

    Save and copy your client ID (and secret).

    My script worked after I created the new OAUTH credential, assigned the origin, and used the newly generated client ID following this process.

    0 讨论(0)
  • 2020-12-08 13:44

    If you are running it on localhost change the port to 5000 and it will fix it

    0 讨论(0)
  • 2020-12-08 13:49

    I got the error because of Allow-Control-Allow-Origin: * browser extension.

    0 讨论(0)
提交回复
热议问题