Javascript Safari Can';在GoogleOAuth回调后无法获取Uri片段
我正在按照以下文档实现Google OAuth 2.0: 我设置了以下步骤:Javascript Safari Can';在GoogleOAuth回调后无法获取Uri片段,javascript,oauth-2.0,google-authentication,Javascript,Oauth 2.0,Google Authentication,我正在按照以下文档实现Google OAuth 2.0: 我设置了以下步骤: 用户单击登录按钮并打开一个新窗口 格式化验证url并将新窗口重定向到Google 用户完成身份验证登录,谷歌将访问令牌重定向到我的回调 回调页面使用#(例如:https://oauth2-login-demo.appspot.com/oauthcallback#access_token=1/fFBGRNJru1FQd44AzqT3Zg&token_type=Bearer&expires_in=3600&nonce=Dg
https://oauth2-login-demo.appspot.com/oauthcallback#access_token=1/fFBGRNJru1FQd44AzqT3Zg&token_type=Bearer&expires_in=3600&nonce=DgkRrHXmyu3KLd0KDdfq
)我的部分代码:
- 第一步
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 Repo:Github.com/bblurock/parse cloud with google twitter oauth/blob/master/index.js#L22-L40
(很抱歉给您带来不便,我的声誉不足以发布两个以上的链接)
- Github Repo:Github.com/bblurock/parse cloud with google twitter oauth/blob/master/index.js#L22-L40
。
在我的情况下,我使用的是重定向urihttp://localhost:8080/auth-callback.html/
是我的本地服务器重定向到的http://localhost:8080/files/auth-callback.html/
在您的示例中,您提到了重定向uri
https://oauth2-login-demo.appspot.com/oauthcallback
。当我转到该uri时,我不会被重定向到其他任何地方,因此这在您的特定情况下可能没有用处,但如果该页面有更明确的路径,那么也许可以尝试一下
很抱歉,如果这不能解决您的问题,但我相信它会帮助其他人解决类似的问题。我也遇到过同样的问题,使用Asana的API和Oauth创建一个应用程序……在Chrome、FF甚至IE 11上都很好,但在Safari上没有 这就是最终对我起作用的原因: Safari在重定向URI的末尾需要一个“/”: “”
这不包括重定向URI末尾的实际文件,即“index.php”。我也遇到了这个问题,你解决了吗?我也遇到了同样的问题,你找到解决方案了吗?那么请大家分享,这样我就能解决这个问题了