javascript - Google OAuth 2.0 SAMEORIGIN Error - Stack Overflow

This is a question as old as time. But how do I get around the SAMEORIGIN error when using googles java

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 badges
Add a ment  | 

1 Answer 1

Reset to default 8

Have you tried immediate: false

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745567513a4633484.html

相关推荐

  • javascript - Google OAuth 2.0 SAMEORIGIN Error - Stack Overflow

    This is a question as old as time. But how do I get around the SAMEORIGIN error when using googles java

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信