我有用户注册到我的网站并连接了他们的 Google+ 帐户,我想从打包的 Chrome 应用程序中自动登录。
我正在关注 [1] 和相关示例 [2]。
我可以成功执行 Google 帐户身份验证并获取令牌和用户信息。接下来,我想将 Google 令牌“交换”为“我的网站”令牌。
我在想:
- 应用程序将令牌和 user_id 发送到服务器
- 服务器请求https://www.googleapis.com/plus/v1/people/me并验证 user_id 和令牌匹配
- 服务器搜索与(google)user_id对应的用户并登录
另一种方法是实现一个 oauth 登录表单并遵循 [1] 中的非 Google 帐户身份验证,但这对我来说似乎太多额外的工作。
有什么建议/替代方式吗?
[1] http://developer.chrome.com/apps/app_identity.html
[2] https://github.com/GoogleChrome/chrome-app-samples/tree/master/identity