Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google API error, but still works

Im getting this console error on my localhost when connecting to google drive API, but the picker I have configured in my script successfully displays my drive's contents:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://docs.google.com') does not match the recipient window's origin ('http://localhost:8000').

Invalid 'X-Frame-Options' header encountered when loading 'https://docs.google.com/picker?protocol=gadgets&origin=http%3A%2F%2Flocalho…2photos%22))&rpctoken=yxxydsx40r21&rpcService=2dngvfb4tj9x&thirdParty=true': 'ALLOW-FROM http://localhost:8000' is not a recognized directive. The header will be ignored.

Do I ignore this or will it introduce trouble for me down the road?

like image 541
redress Avatar asked Apr 15 '15 18:04

redress


People also ask

How do I know if my Google API is working?

Go to the Credentials section, which can be accessed from the left side bar under Google Maps Platform > Credentials. Check that the API key you currently use on your website is listed.

How do I see Google API errors?

Google APIs define a set of standard error payloads for error details, which you can find in google/rpc/error_details. proto. These cover the most common needs for API errors, such as quota failure and invalid parameters. Like error codes, developers should use these standard payloads whenever possible.

How do I fix an API error?

To fix this, check with your API provider to see if there is a testing environment that doesn't utilize caching. Alternatively, double check your API call on a different machine or with a different set of credentials. You can also check your API documentation to see if there's some cache invalidation method available.


2 Answers

This is a CORS issue Cross Origin Resource Sharing. You will need to add CORS on your server so that it sets correct headers. What is CORS and how to solve

Read up on: Wrong Origin using HTTPRequests

like image 139
Bojoer Avatar answered Oct 10 '22 16:10

Bojoer


This is a bug

https://issuetracker.google.com/issues/177046274

There seems to be a few workarounds there for people using it as part of an Apps Script Add-on, making reference to this stack question:

Google Picker API Invalid origin value error

Though this doesn't work for the official quickstart using JavaScript.

I have tested this with Chrome and Firefox and both give the same results.

If this is affecting you please be sure to go and star the issue linked above.

like image 43
iansedano Avatar answered Oct 10 '22 15:10

iansedano