spring-projects / spring-authorization-server

Spring Authorization Server
https://spring.io/projects/spring-authorization-server
Apache License 2.0
4.78k stars 1.25k forks source link

oauth2/token 返回 unsupported_grant_type #1637

Closed guyangxizhao closed 1 month ago

guyangxizhao commented 1 month ago

response: { "error_description": "OAuth 2.0 Parameter: grant_type", "error": "unsupported_grant_type", "error_uri": "https://datatracker.ietf.org/doc/html/rfc6749#section-5.2" }

版本 问题依旧
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-oauth2-authorization-server</artifactId>
        <version>1.3.0</version>
    </dependency>
guyangxizhao commented 1 month ago

1.获取code http://127.0.0.1:8081/oauth2/authorize?response_type=code&client_id=admin&redirect_uri=https://www.baidu.com&scope=openid&state=normal 2.获取token 使用form提交参数 url:http://127.0.0.1:8081/oauth2/token grant_type:authorization_code redirect_uri:https://www.baidu.com code: <通过上一步获取的code> client_assertion_type:urn:ietf:params:oauth:client-assertion-type:client_secret_basic <因为使用client_secret_basic作为client认证类型,是标准的basic-auth,所有需要在header添加 Authorization> <Authorization:Basic base64(client-id:client-secret) 空格不可少>