【发布时间】:2016-04-04 08:19:53
【问题描述】:
我正在按照此文档实施 Google OAuth 2.0:https://developers.google.com/identity/protocols/OAuth2UserAgent
我设置了以下步骤:
- 用户单击登录按钮并打开一个新窗口。
- 格式化验证 URL 并将新窗口重定向到 Google。
- 用户完成身份验证登录,Google 将 access_token 重定向到我的回调
- 回调页面使用#(例如:
https://oauth2-login-demo.appspot.com/oauthcallback#access_token=1/fFBGRNJru1FQd44AzqT3Zg&token_type=Bearer&expires_in=3600&nonce=DgkRrHXmyu3KLd0KDdfq)验证URI片段中返回的access_token
我的问题是,对于 Chrome 和 Firefox,它工作得很好。但是,桌面 Safari(9.0.1) 和移动 Safari(iOS 9.2) 都无法接收任何哈希参数:Safari Console
是我执行了错误的 OAuth 步骤吗?
我的部分代码:
-
第一步
let that = this; let oauthWindow = window.open("", "oauthWindow", "height=518,width=964"); that.setState(Object.assign({}, that.state, {loaded: false})); Parse.Cloud.run("google_util_request_login").then(function(result) { console.log(decodeURIComponent(result)); oauthWindow.location = decodeURIComponent(result); }, function (error) { that.setState(Object.assign({}, that.state, {errorMessage: error, loaded: false})); }); -
第 2 步:google_util_request_login 是一个云函数,它将返回格式化 url。
- Github 存储库:github.com/bblurock/parse-cloud-with-google-twitter-oauth/blob/master/index.js#L22-L40
(很抱歉给您带来不便,我的声誉不足以发布两个以上的链接)
- Github 存储库:github.com/bblurock/parse-cloud-with-google-twitter-oauth/blob/master/index.js#L22-L40
【问题讨论】:
-
我也遇到了这个问题,你解决了吗?
-
我也遇到了同样的问题,你找到解决办法了吗?然后请分享,以便我能够解决这个问题
标签: javascript oauth-2.0 google-authentication