如何在 Spring Boot 中使用 WebClient 替换 OAuth2RestTempate 的密码授予类型实现

问题描述

我有以下 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 替换它以执行相同的操作,但似乎没有一种简单的方法可以做到这一点。 任何线索表示赞赏。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...