gpt4 book ai didi

oauth-2.0 - Google Home App,无法让 OAUTH 正常工作

转载 作者:行者123 更新时间:2023-12-04 05:32:02 28 4
gpt4 key购买 nike

我们正在为 google home 使用 google 上的操作构建一个智能家居应用程序。我们的应用程序需要登录我们的系统才能访问用户设备,以便他们可以通过 google home 使用语音控制他们。我们的用户后端是使用 AWS Cognito 构建的。我们使用 API.AI 作为 Google Home 应用的一部分。

我已经将 Cognito OAUTH2 端点和谷歌应用程序上的操作配置为使用身份验证代码流和不同的范围相互协作,但是我缺少一些东西。当我尝试将用户帐户链接到 Google Home 应用程序时,我被重定向到我们的登录页面。填写用户详细信息后,我返回到 Google Home 的“发现”选项卡,但底部有一条消息指出:“身份验证代码交换中的 IdP 响应错误”。

我也尝试过使用 Google 的 OAUTH2 游乐场。似乎在使用它时我可以从我们的 OATUH 服务器获取代码,但是在尝试将代码交换为 token 时,我收到以下错误:

HTTP/1.1 400 Bad Request
Strict-transport-security: max-age=31536000 ; includeSubDomains
X-content-type-options: nosniff
X-application-context: application:prod:8443
Transfer-encoding: chunked
Set-cookie: XSRF-TOKEN=35f58337-76f4-4993-a0c9-93429134ea42; Path=/; Secure; HttpOnly
Expires: 0
Server: Server
Connection: keep-alive
X-amz-request-id: 284d862e-b021-4079-b5f5-3cbce675983c
X-xss-protection: 1; mode=block
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Wed, 23 Aug 2017 13:51:42 GMT
X-frame-options: DENY
Content-type: application/json;charset=UTF-8
{
"error": "invalid_client"
}

我已经检查并重新检查了客户端 ID 和客户端密码等,但没有发现任何错误。

有谁知道我如何解决这个问题?

提前致谢

最佳答案

好的,我可能知道原因.....如果您使用 aws cognito ...
根据此文档( http://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html )

授权
如果向客户端发布了 secret ,则客户端必须通过基本 HTTP 授权在授权 header 中传递其 client_id 和 client_secret。 secret 是基本 Base64Encode(client_id:client_secret)。

他们需要将客户端和客户端 sectet 放在标题中......

然后我使用 aws http proxy 捕获了 google progress 的请求。

Method request headers: {X-Cloud-Trace-Context=d7b6b9b8239965baf69acab659e80a01/13879251242019662389, CloudFront-Viewer-Country=US, CloudFront-Forwarded-Proto=https, CloudFront-Is-Tablet-Viewer=false, CloudFront-Is-Mobile-Viewer=false, User-Agent=google-oauth-playground AppEngine-Google; (+http://code.google.com/appengine; appid: s~oauth2playground), X-Forwarded-Proto=https, CloudFront-Is-SmartTV-Viewer=false, Host=en75z5h2rb.execute-api.us-east-1.amazonaws.com, Accept-Encoding=gzip, deflate, X-Forwarded-Port=443, X-Amzn-Trace-Id=Root=1-5a0fcef2-09197cd86a625ad47d78f0b7, Via=1.1 d63a8908759a2f4775b3f672ebf823cc.cloudfront.net (CloudFront), X-Amz-Cf-Id=nFdLK97vAS5HvmpNYkPpbUMOB4bCaM6pScHWTAReAnonLg1gXF7hSg==, X-Forwarded-For=107.178.195.199, 54.182.238.53, content-type=application/x-www-form-urlencoded, CloudFront-Is-Desktop-Viewer=true}

请求 header 中没有授权。所以 Cognito 会回来
"error": "invalid_client"

根据此 OAUTH2.0 规范 ( https://tools.ietf.org/html/rfc6749#section-2.3.1 )

我已经问过 AWS 支持了。他们说:

Thanks for contacting AWS Support and providing us with detailed references. I would be happy to assist with your question regarding Cognito supporting client credentials in the request-body.

After reading through the OAUTH2.0 Standards RFC 6749 [0], It looks like including the client credentials in the request-body is not recommended. Here's an excerpt on the spec:

"Including the client credentials in the request-body using the two parameters is not recommended and should be limited to clients unable to directly utilize the HTTP Basic authentication scheme (or other password-based HTTP authentication schemes)."

关于oauth-2.0 - Google Home App,无法让 OAUTH 正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45841730/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com