Google API: Invalid origin for client: url was not whitelisted for client id "

I need help. I did not find the answer to my question. I tried to take a walk, and I tried to ask from other parties, but I did not find the answer.

I work with the Google API (Youtube Data API) and I use the google example code that it works. I am sure about that. I got an error when I try to run Script:

more details: “Invalid origin for client:“ MyURL ”was not whitelisted for client identifier“ MyID. ”Go to https://console.developers.google.com/ and enter a whitelist for your project client identifier.

error: "idpiframe_initialization_failed"

The problem is that I selected my website and accepted it. I do not know what is wrong. What should I do for the "white list" of my domain (it is included in the white list)

And one more question. I have not looked for an answer to this question before.

I think it is possible that I can use the code on Localhost, I think I should change the white address of my local host or something like this. But the whitelist does not work.

  • Dreamgamer
+60
source share
13 answers

There was the same problem, and here is how I solved it:

  • Activate the API and Google Plus API in your project
  • Creating New OAUTH 2.0 Client Credentials
    • Add Authorized Javascript Origins to the Limitations Section
  • Use a new customer identifier.

Enjoy.

+47

. .

Chrome: → → →

+127

, cache/localstorage.

+6

API, Google Analytics. , , . , 1- , . 2- . Chrome "" → " " → " " → "" () → ) cookie ) 3-. .

+6

+4

! , , .

" : https://secure.mydomain.com MYCLIENTID. console.developers.google.com/ ." : "idpiframe_initialization_failed"

console.developers.google.com/apis/credentials/domainverification

:

secure.mydomain.com/

, //? , secure.mydomain.com secure.mydomain.com/

... !

+1

: , .

, , : OAuth , API key. OAuth Youtube - (, , ), .

, apiKey clientId gapi.client.init (: API), , :

const apiKey = '<my API key>';

function gooApiInitClient() {
  // Array of API discovery doc URLs for APIs used by the quickstart
  const discoveryDocs = [
    "https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest"
  ];

  return gapi.client.init({
    apiKey,
    discoveryDocs
  });
}

// see: https://developers.google.com/api-client-library/javascript/reference/referencedocs
gapi.load('client', {
  callback: function() {
    // we now have gapi.client! initialize it.
    gooApiInitClient().
      then(() => {
        // we can start using the API here!
        // e.g. gapi.client.youtube.videos.list(...);
      }).then(results => { 
        // use results here....
      });
  }
});
+1

, : " , , , , ".

, CLIENT_ID .

  var CLIENT_ID = '44********-*****************.apps.googleusercontent.com ';

( ), .

, . .

+1

-. OAuth . , . , , .

- Google -, . . , , , API.

- , , .

+1

- , API API Google Analytics. , , , , !

0

, , , : , > a > > : > : .

0

, , (100) client ID.

You can visit the Google APIs console page and create new Oauth2 client credentials (remember to add the URL of your applications in the "section Authorized Javascript Origins), and then use it.

0
source

I had the same problems until I realized when I copied client_ID, there was an empty space in my file, so I removed the empty space from the line and now everything works fine.

0
source

Source: https://habr.com/ru/post/1686561/


All Articles