简体   繁体   English

Google App Engine井字游戏Java示例OAUTH失败

[英]Google App Engine Tic Tac Toe Java Example OAUTH fails

I am trying to learn to use Google App Engine and not having much luck. 我正在尝试学习使用Google App Engine,但运气不佳。

Has anyone gotten the Tic Tac Toe example for Google App Engine(Java version) to work? 有人听说过井字游戏示例,可让Google App Engine(Java版)正常工作吗? I have been trying to get this example to work - developers.google.com/appengine/docs/java/endpoints/ 我一直在尝试使此示例正常工作developers.google.com/appengine/docs/java/endpoints/

This is the code for it - 这是它的代码-

`github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-java`

While I can get the app up and running , I can't get the OAUTH part it to work/authenticate . 虽然我可以启动并运行该应用程序,但我无法使它的OAUTH部分正常工作/进行身份验证。

The second ,lesser, problem is I am trying to use the web client part of it but it doesn't find the app from a browser unless run it via the api explorer. 第二个较小的问题是我试图使用Web客户端的一部分,但是除非通过api Explorer运行它,否则它不会从浏览器中找到该应用程序。 If I wrap it in - ../_ah/api/explorer , I can get it to make make an unauthorized call (getmove()) but any of the other methods do not work. 如果将其包装在-../_ah/api/explorer中,则可以进行未经授权的调用(getmove()),但其他任何方法均无效。

The functions that require oauth fail miserably. 需要oauth的功能严重失败。

I even have my google plus email listed in the permissions of the app . 我什至在应用程序的权限中列出了我的google plus电子邮件。 I'll even be logged in to Google Plus and the OAUTH fails. 我什至将登录到Google Plus,并且OAUTH失败。

I changed the client id where the readme file directed. 我更改了自述文件指向的客户端ID。

I get the following response. 我得到以下回应。

401 Unauthorized 401未经授权

  • Show headers - 显示标题-

    { "error": { "message": "com.google.appengine.api.oauth.OAuthRequestException: Invalid user.", "code": 401, "errors": [ { "domain": "global", "reason": "required", "message": "com.google.appengine.api.oauth.OAuthRequestException: Invalid user." {“错误”:{“消息”:“ com.google.appengine.api.oauth.OAuthRequestException:无效的用户。”,“代码”:401,“错误”:[{“域”:“全局”,“原因“:“必需”,“消息”:“ com.google.appengine.api.oauth.OAuthRequestException:无效的用户。” } ] } } }]}}

This has taken way too long . 这花了太长时间。 Any help would be useful. 任何帮助将是有用的。

Thanks. 谢谢。

The reason the OAUTH2 fails is because you haven't filled out the Consent Screen options. OAUTH2失败的原因是,您尚未填写“同意屏幕”选项。 Go to your cloud dashboard then "APIs & auth" -> "Consent screen". 转到您的云仪表板,然后单击“ API和身份验证”->“同意屏幕”。 Fill out Product Name and EMail. 填写产品名称和电子邮件。 It takes about a minute to go through. 大约需要一分钟。 After that the OAUTH2 should work. 之后,OAUTH2应该工作。

Reference: https://stackoverflow.com/a/18951654/1639019 参考: https : //stackoverflow.com/a/18951654/1639019

Not sure if you are having the same problem I did, but there are two places where you have to change the clientid once you've generated a clientid using the developers console. 不知道您是否遇到了与我相同的问题,但是一旦使用开发人员控制台生成了clientid,就必须在两个地方更改clientid。 One place is located inside the Constants or a variable passed into the java runtime server (development or deployment) the other is located in a file called base.js (in my hello endpoints example) located in the webapp/js folder. 一个位置位于Constants或传递到Java运行时服务器(开发或部署)的变量中,另一个位于webapp / js文件夹中名为base.js的文件中(在我的hello端点示例中)。 You must have everything configured through the developers console in order for the oauth2 redirects to work properly. 您必须通过开发人员控制台配置所有内容,才能使oauth2重定向正常工作。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM