[我正在尝试使用spirng-oauth2-client将我的项目与第三方身份验证服务器连接(此instruction之后),现在当我运行该应用程序时,在授权步骤之后,我将重定向回我的应用程序,并显示带有此错误的页面:
[invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: 406 Not Acceptable: [Media is not supported]
[在另一个Stack Overflow帖子中的comments for an answer中,有人建议这样做是因为“ Spring使用FORM参数对身份验证代码进行POST,而mercadolibre期望没有正文,只希望查询参数”。
我现在有此配置:
application.properties
spring.security.oauth2.client.registration.mercadolivre.provider=mercadolivre
spring.security.oauth2.client.registration.mercadolivre.client-id=...
spring.security.oauth2.client.registration.mercadolivre.client-secret=...
spring.security.oauth2.client.registration.mercadolivre.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.mercadolivre.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
spring.security.oauth2.client.provider.mercadolivre.authorization-uri=https://auth.mercadolivre.com.br/authorization
spring.security.oauth2.client.provider.mercadolivre.token-uri=https://api.mercadolibre.com/oauth/token
security.java
@Configuration
public class Security extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.oauth2Login()
.defaultSuccessUrl("/");
}
}
任何人都知道如何更改Spring行为以匹配该服务所需的行为?我的意思是,使验证代码的POST没有主体,只有查询参数?