最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Why do the Spring docs refer to a deprecated class in their OAuth example and how do I change it to avoid using the depre

programmeradmin0浏览0评论

I am trying to validate the audience of the authToken received by the Spring Boot app. I saw this, but when I try to do it I get the following...

'DefaultAuthorizationCodeTokenResponseClient' is deprecated. Deprecated in Java

'OAuth2AuthorizationCodeGrantRequestEntityConverter' is deprecated. Deprecated in Java

This comes from the lines

val requestEntityConverter = OAuth2AuthorizationCodeGrantRequestEntityConverter()
val accessTokenResponseClient = DefaultAuthorizationCodeTokenResponseClient()

What should I be using instead since this is the latest docs? When I try to debug into the code I do not see an alternative in the javadocs?

Per the comments I tried changing to

    @Bean
    fun authorizationCodeAccessTokenResponseClient(): OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> {
        val requestEntityConverter =  DefaultOAuth2TokenRequestParametersConverter()
        requestEntityConverter.addParametersConverter(parametersConverter())

        val accessTokenResponseClient =  RestClientAuthorizationCodeTokenResponseClient()
        accessTokenResponseClient.setRequestEntityConverter(requestEntityConverter)

        return accessTokenResponseClient
    }

But then I get

Not enough information to infer type variable T

Unresolved reference: setRequestEntityConverter

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论