【发布时间】:2019-12-04 18:01:22
【问题描述】:
我正在尝试在 micronaut 中使用 Bitbucket Oauth 设置 Oauth2 授权代码流。 我已经在我的 Mirconaut 配置中为身份验证设置了 Github 和 Bitbucket。
每当我(尝试)使用 Bitbucket 登录时,都会收到 redirect_uri 不匹配错误。
{"message":"Internal Server Error: error: invalid_request, errorDescription: redirect_uri does not match, errorUri: null"}
在进行一些研究并启用一些跟踪日志记录后,我发现访问令牌请求中缺少 redirect_uri。
09:33:53.263 [nioEventLoopGroup-1-5] DEBUG i.m.http.client.DefaultHttpClient - Sending HTTP Request: POST /site/oauth2/access_token
09:33:53.263 [nioEventLoopGroup-1-5] DEBUG i.m.http.client.DefaultHttpClient - Chosen Server: bitbucket.org(-1)
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - Accept: application/json
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - Authorization: Basic xxxxxxx
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - content-type: application/x-www-form-urlencoded
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - host: bitbucket.org
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - connection: close
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - content-length: 53
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - Request Body
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - ----
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - code=PuaUDFGTmQ4Gh9gJPM&grant_type=authorization_code
09:33:53.264 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - ----
09:33:53.762 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - HTTP Client Response Received for Request: POST https://bitbucket.org/site/oauth2/access_token
09:33:53.762 [nioEventLoopGroup-1-5] TRACE i.m.http.client.DefaultHttpClient - Status Code: 400 Bad Request
每当我使用 curl 之类的东西重新创建调用并添加(默认)redirect_uri 时,我都会取回正确的访问令牌并能够使用它。
有没有办法将redirect_uri 添加到令牌请求中?这是一个错误吗?据我所知,如果之前的授权请求中也存在redirect_uri,则令牌请求中需要redirect_uri(请参阅https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3)
谢谢,
丹尼
【问题讨论】:
-
这似乎是一个错误,请提出问题
标签: oauth-2.0 bitbucket micronaut