Library to integrate Google's OAuth/OpenID hybrid in Java Web App?

与世无争的帅哥 提交于 2019-11-27 21:37:06

I don't know any integrated library but I do it with an OpenID library (openid4java), an OAuth library (net.oauth Java implementation [Edit: or Scribe]) and my bare hands as follows:

My OAuth consumer key is like www.example.com so I use http://*.example.com as OpenID realm.

I add following parameters (to redirect url or form) when redirecting user to Google OpenID endpoint:

openid.ns.ext2=http://specs.openid.net/extensions/oauth/1.0
openid.ext2.consumer=<my oauth consumer key>
openid.ext2.scope=<oauth scope to be authorized>

In return in addition to plain OpenID response I receive:

openid.ext2.request_token=<request-token>

I exchange received request-token with access-token and access-secret which are what is needed to make OAuth-authorized calls. That's all!

Note that in plain OAuth along with request-token you have to use a request-secret and verifier but here you don't need them.

To have a better view you may read Google OAuth, Google OpenID and OpenID OAuth Extension.

Edit: Here (comment 8) is the OAuth extension for openid4java that does above for you.

It does not support OpenID but, Scribe is a very good OAuth Java library that supports Google.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!