javascript Google Drive API OAuth 2.0;错误:origin_mismatch

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15424441/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 00:44:05  来源:igfitidea点击:

Google Drive API OAuth 2.0; Error: origin_mismatch

javascriptgoogle-drive-apigoogle-drive-realtime-api

提问by bluejayke

I'm having trouble creating a valid google drive API for my website. I may sound like a complete noob, but I created a file called quickstart.html in my main ftp directory and copied and pasted the code from https://developers.google.com/drive/quickstart-js#step_1_enable_the_drive_apiand replaced the client id with my client id, and in my settings I set the Javascript Origins URL to my main url (www.domainname.com), I have a separate index page for that domain, so to access google drive do I just go to http://domainname.com/quickstart.html? Because when I do that and click "Authorize" I get the google Origin Mismatch error. Can anyone help me please?

我在为我的网站创建有效的 Google Drive API 时遇到问题。我可能听起来像一个完整的菜鸟,但我在我的主 ftp 目录中创建了一个名为 quickstart.html 的文件,并从https://developers.google.com/drive/quickstart-js#step_1_enable_the_drive_api复制并粘贴了代码并替换了客户端id 和我的客户端 id,在我的设置中,我将 Javascript Origins URL 设置为我的主 url (www.domainname.com),我有一个单独的该域的索引页,所以要访问 google drive,我只需转到http: //domainname.com/quickstart.html? 因为当我这样做并单击“授权”时,我收到了 google Origin Mismatch 错误。有人可以帮我吗?

回答by bluejayke

in Api Console replace your redirect urls to http and remove https and You can also use 'scope': 'https://www.googleapis.com/auth/plus.loginhttps://www.googleapis.com/auth/userinfo.email' . This solution worked for me.

在 Api 控制台中,将您的重定向 url 替换为 http 并删除 https,您还可以使用“范围”:“ https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo .email'。这个解决方案对我有用。

回答by garish

Verify that "JavaScript origins:" Property under Section "Client ID for web applications" and the URL of the page on which you are applying the login code must be same.

验证“Web 应用程序的客户端 ID”部分下的“JavaScript origins:”属性与您应用登录代码的页面的 URL 必须相同。

回答by Randomparanoid

Make sure that you are actually accessing www.domainname.com not just domainname.com. Some browsers will hide the actual url until you copy-paste the url into another program. Make sure you type the whole URL, with the http and the www. to be absolutely sure.

确保您实际上访问的是 www.domainname.com,而不仅仅是 domainname.com。一些浏览器会隐藏实际的 url,直到您将 url 复制粘贴到另一个程序中。确保键入整个 URL,包括 http 和 www。要绝对确定。