2016-06-13 130 views
0

我开发了一个html5页面来列出谷歌驱动器文件并使用PhoneGap服务器进行测试。所有工作正常,因为我创建了一个配置为http://localhost:3000的Oauth2。Android App + Cordova + HTML5 + Google Drive Api

当我试图测试APK文件,与SHA1(也的oauth2配置在谷歌驱动器控制台),我收到的错误:

Refused to display 'https://accounts.google.com/o/oauth2/auth?client_id=<KEY>' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. I understand that this error is because the Oauth2 doesn't expect the origin. But the Origin is not http, if file know... (file:///android_asset/www/index.html). The GoogleAPI Console doesn't accept 'file' protocol... just 'http'.

我该如何解决这个问题?

+0

你可以检查我的答案在类似的SO问题(http://stackoverflow.com/questions/35746756/how-implement-google-drive-in-ionic-app/42412306#42​​412306) – JcDenton86

回答

0

根据这个给出的SO后的解决方案 - Refused to display in an frame because it set 'X-Frame-Options' to 'SAMEORIGIN',就遇到错误:

This is not related to disabling security in chrome browser. I believe there might me some issues with my XAMPP Windows local host.Deploying the same application in node.js server or hosting Dropbox/Google Drive as a web app also works fine.

此外,提出请求,如步骤#2从basic steps在使用OAuth 2.0访问谷歌API的讨论,从Google授权服务器获取访问令牌。办法提出请求如下:

  • 一个JavaScript应用程序可能使用浏览器重定向到谷歌
  • 安装不具备浏览器使用的Web服务请求的设备上的应用程序请求访问令牌。

您可以使用的示例场景可以在文档中找到。