Spring-security-oauth: Could not autowire OAuth2ClientContext in oauth2 client

Created on 25 Jan 2018  路  2Comments  路  Source: spring-projects/spring-security-oauth

In oauth2 client , it's showing error for not able to resolve OAuth2ClientContext injection in the following code. Error: 'Could not autowire. There is more than one bean of OAuth2ClientContext Type'. Any solution?

@Bean
    public OAuth2RestOperations restTemplate(OAuth2ClientContext oauth2ClientContext) {
        return new OAuth2RestTemplate(resource(), oauth2ClientContext);
    }

waiting-for-triage

Most helpful comment

Try first to autowire using the qualifier as follows

@Autowired
@qualifier("oauth2ClientContext")
OAuth2ClientContext oAuth2ClientContext;

All 2 comments

Try first to autowire using the qualifier as follows

@Autowired
@qualifier("oauth2ClientContext")
OAuth2ClientContext oAuth2ClientContext;

A very strange thing. I hope this will be fixed.
Kotlin:

@Autowired @Qualifier("oauth2ClientContext") private val oauth2ClientContext: OAuth2ClientContext
Was this page helpful?
0 / 5 - 0 ratings