Google Contacts API: No 'Access-Control-Allow-

2019-02-24 07:51发布

After working perfectly for about a month, I'm now getting a

No 'Access-Control-Allow-Origin' header is present on the requested resource.

Here's a simplified version of the ajax request.

var feedurl = "https://www.google.com/m8/feeds/contacts/EMAIL/full?oauth_token=TOKEN&max-results=50&alt=json&v=3.0";

$.ajax({
        url: feedurl,
        dataType: "json",
        success: function(data) {
            console.log(data);
            //do stuff
        }
    });

Changing dataType to jsonp doesn't change anything. In the google api console I have Accept requests from these HTTP referrers (web sites) set to https://*.MYWEBSITE.com/*

My only thought is that maybe Chrome/Safari became more restrictive in the latest updates.

1条回答
爷的心禁止访问
2楼-- · 2019-02-24 08:27

It seems that our service starts to getting the error of

Refused to execute script from 'https://www.google.com/m8/feeds/contacts/default/thin?v=3.0&access_token=...&max-results=5000&alt=json&callback=...&_=...'
because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled`

right after the issue is fixed here...

We use ajax + jsonp to fetch data from google contacts.
Has anyone else experienced the same thing? And who knows how to fix it?

查看更多
登录 后发表回答