This is a question as old as time. But how do I get around the SAMEORIGIN error when using googles javascript API?
From their example:
let clientId = 'CLIENT_ID';
let apiKey = 'API_KEY';
let scopes = '.readonly';
gapi.client.setApiKey(apiKey);
setTimeout(() => {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, (authResult) => {
console.log(authResult);
});
});
I get:
Refused to display '. . .' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
I have my API Key set as a Browser Key. And the Client ID set as a Web Application.
I am trying to test this via localhost which may be a problem. So on the API Key I added http://localhost:8000 to Authorized JavaScript Origins- Which may not make sense but it was worth a shot I thought.
The API key is not restricted to any domain and there is no domain verification for the OAuth verification screen.
I've also tried running chrome with --disable-web-security but no luck.
This is a question as old as time. But how do I get around the SAMEORIGIN error when using googles javascript API?
From their example:
let clientId = 'CLIENT_ID';
let apiKey = 'API_KEY';
let scopes = 'https://www.googleapis./auth/youtube.readonly';
gapi.client.setApiKey(apiKey);
setTimeout(() => {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, (authResult) => {
console.log(authResult);
});
});
I get:
Refused to display '. . .' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
I have my API Key set as a Browser Key. And the Client ID set as a Web Application.
I am trying to test this via localhost which may be a problem. So on the API Key I added http://localhost:8000 to Authorized JavaScript Origins- Which may not make sense but it was worth a shot I thought.
The API key is not restricted to any domain and there is no domain verification for the OAuth verification screen.
I've also tried running chrome with --disable-web-security but no luck.
Share Improve this question asked Apr 19, 2016 at 11:41 micahmicah 8,13610 gold badges63 silver badges103 bronze badges1 Answer
Reset to default 8Have you tried immediate: false
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745567513a4633484.html
评论列表(0条)