简体   繁体   English

GET /oauth/token with grant_type=authorization_code 返回未授权

[英]GET /oauth/token with grant_type=authorization_code returns unauthorized

I am using spring boot oauth2 trying to set up an authorization code grant flow.我正在使用 spring boot oauth2 尝试设置授权代码授予流程。 The authorize endpoint works, generates a code and stores it in our postgres store.授权端点工作,生成代码并将其存储在我们的 postgres 存储中。 However the second step to get a token from using the code does not work.但是,使用代码获取令牌的第二步不起作用。

I've not modified anything with grant_types (like with TokenGranter ) that's still all as default in spring.我没有用 grant_types 修改任何东西(比如用TokenGranter ),这在春天仍然是默认的。

I am not sending over a principle.. I believe the authorization_code takes over that?我不是在发送原则..我相信授权代码会接管吗?

I call something like:我称之为:

GET http://localhost:8088/<my_spring_app>/oauth/token?
grant_type=authorization_code&client_secret=<client_secret>
&redirect_uri=<redirect_to_flask_app>&code=Q6PNye
&scope=<three>+<scope>+<types>&client_id=<my_id>

I receive:我收到:

{
    "timestamp": 1520635615344,
    "status": 401,
    "error": "Unauthorized",
    "message": "Full authentication is required to access this resource",
    "path": "/<my_spring_app>/oauth/token"
}

I'm still new to spring so I don't know where to start looking into the Spring code to find why it doesn't believe I'm authenticated.我对 spring 还是个新手,所以我不知道从哪里开始查看 Spring 代码以找出为什么它不相信我已通过身份验证。

Does anyone know where to even start looking?有谁知道从哪里开始寻找? Thanks!!谢谢!!

You are not implementing OAuth2,您没有实施 OAuth2,
I can see in the response Location is again /<my_spring_app>/oauth/token same server calling same server, its not OAuth2,我可以在响应中看到 Location 再次是/<my_spring_app>/oauth/token相同的服务器调用相同的服务器,它不是 OAuth2,
your server should have called another server OAuth2 implemented to authenticate your service,您的服务器应该调用另一个服务器 OAuth2 来验证您的服务,
so in response you must have received another service url to hit like example google.com/oauth2/authorize/code=something...因此,作为回应,您必须收到另一个服务 url 以点击示例google.com/oauth2/authorize/code=something...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在 Spring Boot 中为 oauth2 在同一个项目中同时使用 grant_type=password 和 grant_type=authorization_code - Can i use both grant_type=password and grant_type=authorization_code in same project for oauth2 in spring boot 如何通过授权类型的授权与苹果登录(Java) - How to sign in with apple by the grant type of authorization_code (Java) 针对OAuth2authorization_code发布请求获取无效赠款以进行Google Play结算购买验证 - Getting Invalid Grant on OAuth2 authorization_code post request for Google Play Billing purchase verification Spring-Security-OAuth2中的grant_type - grant_type in Spring-Security-OAuth2 Google Oauth2身份验证返回“缺少必需的参数:grant_type” - Google Oauth2 authentication returns “Required parameter is missing: grant_type” Java中没有web浏览器是否可以在OAuth 2.0中获取authorization_code? - Is it possible to get authorization_code in OAuth 2.0 without web browser in Java? 如何在 Spring Boot Oauth2 授权服务器中 grant_type=client_credentials 时抛出错误凭据的任何异常 - How to throw any Exceptions for wrong credentials when grant_type=client_credentials in Spring Boot Oauth2 Authorization Server 实现授权码流授予类型OAuth2 - Implementing authorization code flow grant type OAuth2 google oauth api v2中缺少grant_type参数? - missing grant_type parameter in google oauth api v2? 正在访问Google oAuth,但授予的Grant_type无效(错误请求) - Accessing Google oAuth giving invalid grant_type (Bad request)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM