持久 Google OpenID+OAuth?
我正在开发一个网络应用程序,需要频繁访问 Google 数据 API,因此我决定采用“OAuth with Federated Login(混合协议)”方法让用户登录该应用程序。我让 http://googlecodesamples.com/hybrid/ 正常工作(在对 PHP 5.3 兼容性进行一些调整之后),并且能够获得访问令牌。下一步是什么?如何使用此访问令牌?
看来我需要为用户创建一个本地会话来浏览应用程序的其余部分。这是否需要完全独立于 Google 登录,或者您将如何处理?
相关:该应用程序还需要一个 REST API,我计划使用 OAuth。关于如何将其与实际应用程序的身份验证结合起来有什么建议吗?
I'm working on a web app that will require somewhat frequent access to Google Data APIs, so I decided to go with the "OAuth with Federated Login (Hybrid Protocol)" method for users to log into the app. I got the http://googlecodesamples.com/hybrid/ working (after some tweaks for PHP 5.3 compatibility), and am able to get an Access Token. What's the next step? How do I use this access token?
It seems like I'll need to create a local session for the user to browse the rest of the app. Will this need to be completely independent of the Google login, or how would you handle that?
Relevant: this application also needs a REST API, for which I was planning to use OAuth. Any recommendation on how to tie this in with authentication for the actual app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在使用 PHP LightOpenID 库(参见 gitorious)。它为我们处理所有身份验证流程。您无需担心令牌之类的事情。
这里是我显示“使用 Google 登录”链接的页面:
当点击该链接时,会出现一个 Google 页面,要求他进行身份验证和/或授权您检索他的电子邮件。
然后他将被重定向到登陆页面
$openid->returnUrl
。该页面的代码应该是:如果您想从用户那里检索更多信息,您必须将它们添加到第一页的
$openid->required
中。例如:如果用户接受,您将可以在第二页中获取他的名字和姓氏:
然后,对于 Oauth 部分,您可以按照 此 LightOpenID 问题。
I am using the PHP LightOpenID library (see on gitorious) for that. It handles all the authentication flow for us. You don't need to bother about token and stuff.
Here the page where I display the "Login with Google" link :
When the click on the link, a Google page will appear ask him to authenticate and/or authorize you to retrieve his email.
Then he will be redirect to the landing page
$openid->returnUrl
. The code for that page should be :If you want to retrieve more info from the user, you have to add them to
$openid->required
in the first page. For instance :will let you, if the user accepts it, to get his first and last names as well in the second page :
Then, for the Oauth part, you can follow the instructions of this LightOpenID issue.