【问题标题】:Unsuported grant type: Password - Spring Boot OAuth2不支持的授权类型:密码 - Spring Boot OAuth2
【发布时间】:2018-09-07 00:44:51
【问题描述】:

这是我的 Oauth2Authorization 服务器配置

    @Configuration
    @EnableAuthorizationServer
    class OAuth2AuthorizationServer : AuthorizationServerConfigurerAdapter() {
     // Configures client app
    override fun configure(clients: ClientDetailsServiceConfigurer) {

        clients
                .inMemory()
                .withClient("client")
                .authorizedGrantTypes("password")
                .secret("{noop}secret")
                .scopes("all")
    }

    @Autowired
    private lateinit var authenticationManager: AuthenticationManager

    @Bean
    fun accessTokenConverter(): JwtAccessTokenConverter {
        val converter = JwtAccessTokenConverter()
        converter.setSigningKey(OAuth2ConfigVariables.JWT_SIGNING_KEY)
        return converter
    }

    @Bean
    fun tokenStore(): TokenStore {
        return JwtTokenStore(accessTokenConverter())
    }

    @Throws(Exception::class)
    override fun configure(endpoints: AuthorizationServerEndpointsConfigurer) {
        endpoints.tokenStore(tokenStore())
                .authenticationManager(authenticationManager)
                .accessTokenConverter(accessTokenConverter())
    }


}

这是我的 curl 请求

curl client:secret@localhost:8080/oauth/token -d grant_type=password -d username=user -d password=pwd

我总是得到

{
 "error" : "unsupported_grant_type",
 "error_description" : "Unsupported grant type: password"
}

【问题讨论】:

    标签: spring spring-mvc spring-boot spring-security oauth-2.0


    【解决方案1】:

    希望能帮到你! 也许您应该在http请求授权中添加参数。 例如:

    1. 用户名:xxx(这是客户 ID,在您的项目中是“客户”)
    2. password:xxx(这是客户密码,在您的项目中是“{noop}secret”)
    3. 类型为“基本认证” enter image description here

    邮递员^-^

    【讨论】:

      【解决方案2】:

      这里的问题是:

       .authorizedGrantTypes("password")
      

      密码这个词需要加密才能工作。

      【讨论】:

        猜你喜欢
        • 2019-02-11
        • 1970-01-01
        • 2018-11-09
        • 1970-01-01
        • 2020-01-12
        • 1970-01-01
        • 1970-01-01
        • 2021-04-24
        • 2015-10-30
        相关资源
        最近更新 更多