【问题标题】:developing and testing hybrid google openid + oauth with openid4java on localhost在 localhost 上使用 openid4java 开发和测试混合 google openid + oauth
【发布时间】:2011-03-12 16:43:34
【问题描述】:

我正在尝试实施混合 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/

我正在使用 openid4java。我试着关注这个帖子:library-to-integrate-googles-oauth-openid-hybrid-in-java-web-app

但是当我在 localhost 上测试我的应用程序时遇到了麻烦。

正如您在上述示例请求中看到的,三个属性必须相等:

openid.realm
openid.oauth.consumer
openid.return_to

我在谷歌注册了一些域名并获得了消费者密钥和秘密。但是当我想在本地主机上开发和调试我的应用程序时(即 openid.return_to=http://localhost:8080/ 和 openid.realm=http://*.mydomain.com 和 openid.oauth.consumer=www.mydomain.com)并提供我的密钥和秘密,openid4java RealmVerifier 拒绝了这样的身份验证请求。

我什至尝试提供完全有效的选项(我的注册域而不是本地主机) - 它似乎起作用,但重定向消失了(我不想/不能在该域中部署应用程序,因为缺少技术。)。

您能否建议,如何在本地主机上开发这样的应用程序?有什么技巧可以测试这样的应用程序吗?

感谢您的帮助!

【问题讨论】:

    标签: java openid


    【解决方案1】:

    尝试添加您的 your-machine.your-domain.com 指向 127.0.0.1 在您的开发箱上的 /etc/hosts(在 linux 上),然后以 http://your-machine.your-domain.com 访问您的应用程序

    (注意:将 your-machine 替换为您的机器名称,将 your-domain 替换为您在 Google 注册的域)

    【讨论】:

    • 感谢您的回复。我们最终通过在 AppEngine 上开发简单的 RESTful 身份验证服务解决了这个问题,然后由客户端调用。 (无论如何我们都需要服务器,所以我们选择了这种方式。)
    • @Martin 我认为关于你的问题这个答案是可以接受的。
    猜你喜欢
    • 2011-11-06
    • 2011-03-02
    • 1970-01-01
    • 2011-10-13
    • 1970-01-01
    • 2021-01-22
    • 2013-05-15
    • 2010-10-23
    • 2011-07-11
    相关资源
    最近更新 更多