【问题标题】:Actions On Google Implicit Oauth Flow fails...What's wrong?Google 隐式 Oauth 流上的操作失败...出了什么问题?
【发布时间】:2019-04-24 10:53:19
【问题描述】:

我正在为此处定义的隐式 oauth 流实现我自己的 Oauth 服务器 https://developers.google.com/actions/identity/oauth2?oauth=implicit

看起来很简单,在检查客户详细信息后,我只需要重定向对吗?这就是我遇到问题的地方。文档说重定向 url 必须如下 -

https://oauth-redirect.googleusercontent.com/r/YOUR_PROJECT_ID#access_token=ACCESS_TOKEN&token_type=bearer&state=STATE_STRING

注意 '#'

但是,当您重定向到此 URL 时,这似乎奇怪地弄乱了 google 上的操作,之后我们之前使用的“登录助手”意图暂时似乎起作用,然后失败了。它一定是失败了,但控制台没有显示任何错误

事实上,这个问题仍然存在,我发现删除它的唯一方法是重新创建项目。 (哦,痛苦:/)

但是,当我将“#”替换为“?”时像常规查询字符串一样,重定向后我们会收到 400 错误 -

查询字符串中必须设置参数“code”或“error”。

我不确定我在这里做错了什么。作为参考,这是构造重定向 url 的 JS -

//bearerToken already generated at this point in the code
var redirectUri = params.get("redirect_uri");
var state = params.get("state");
var redirectString = redirectUri;
redirectString+="#access_token="+bearerToken;
redirectString+="&token_type=bearer";
redirectString+="&state="+state;
window.location.href=redirectString;

【问题讨论】:

  • 您是否尝试过将access_token 参数改为code

标签: actions-on-google


【解决方案1】:

我所做的唯一与你不同的事情是使用 window.location.replace 而不是 window.location.href

据我了解,window.location.replace 是模拟 HTTP 重定向的客户端方式。

我的网址看起来像这样https://oauth-redirect.googleusercontent.com/r/project-id#access_token=4cc355t0k3n&token_type=bearer&state=AB8b_TOEy...

【讨论】:

    猜你喜欢
    • 2019-12-05
    • 2016-08-01
    • 1970-01-01
    • 2015-10-06
    • 2021-05-15
    • 1970-01-01
    • 2023-02-16
    • 2020-12-27
    • 1970-01-01
    相关资源
    最近更新 更多