我正在尝试实施混合Google OpenID + OAuth协议,以便识别我的用户并访问他们的Google日历数据.
示例请求如下所示:
https://www.google.com/accounts/o8/id
?openid.ns=http://specs.openid.net/auth/2.0
&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select
&openid.identity=http://specs.openid.net/auth/2.0/identifier_select
&openid.return_to=http://www.example.com/checkauth
&openid.realm=http://www.example.com
&openid.assoc_handle=ABSmpf6DNMw
&openid.mode=checkid_setup
&openid.ns.oauth=http://specs.openid.net/extensions/oauth/1.0
&openid.oauth.consumer=www.example.com
&openid.oauth.scope=http://docs.google.com/feeds/+http://spreadsheets.google.com/feeds/
Run Code Online (Sandbox Code Playgroud)
我正在使用openid4java.我试着关注这篇文章:library-to-integration-googles-oauth-openid-hybrid-in-java-web-app
但是在localhost上测试我的应用程序时遇到了麻烦.
正如您在上述示例请求中所看到的,有三个必须相同的属性:
openid.realm
openid.oauth.consumer
openid.return_to
Run Code Online (Sandbox Code Playgroud)
我已经在谷歌注册了一些域名并获得了消费者密钥和秘密.但是当我想在localhost上开发和调试我的应用程序时(即openid.return_to = http:// localhost:8080 /和openid.realm = http://*.mydomain.com和openid.oauth.consumer = www.mydomain .com)并提供我的密钥和秘密,openid4java RealmVerifier拒绝这样的身份验证请求.
我甚至试图提供完全有效的选项(我的注册域而不是localhost) - 它似乎起作用,但重定向消失了(我不想/不能因为缺少技术而在该域中部署应用程序. ).
你能告诉我,如何在localhost上开发这样的应用程序?有没有什么技巧可以测试这样的应用程序?
谢谢你的帮助!
尝试在开发框中的/ etc/hosts(在linux上)添加指向127.0.0.1的your-machine.your-domain.com,然后将您的应用程序命名为http://your-machine.your-domain. COM
(注意:使用您在Google注册的域名替换您的计算机名称和您的域名)