如何在spring boot中用webclient替换密码授予类型实现的oauth2resttempate

mzaanser  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(134)

我在下面为oauth2resttempate配置了密码授予类型实现,我正在示例化bean:

@Bean
public OAuth2RestTemplate oAuth2RestTemplate() {
    ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
    details.setAccessTokenUri(this.tokenUrl);
    details.setClientId(this.consumerKey);
    details.setClientSecret(this.consumerSecret);
    details.setGrantType("password");
    details.setUsername(this.username);
    details.setPassword(this.password);
    details.setClientAuthenticationScheme(AuthenticationScheme.form);
    OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(details);

    oAuth2RestTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
    return oAuth2RestTemplate;

由于oauth2resttemplate已被弃用,我试图用spring boot webclient替换它以执行相同的操作,但似乎没有一种简单的方法可以做到这一点。任何线索感谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题