Skip to content

Improve error message when invalid content-type for UserInfo response #8764

@sachin21jan

Description

@sachin21jan

Summary

Adding scope: https://www.googleapis.com/auth/contacts.readonly to google oauth2 login generating following exception -

org.springframework.security.oauth2.core.OAuth2AuthenticationException: [invalid_user_info_response] An error occurred while attempting to retrieve the UserInfo Resource: Could not extract response: no suitable HttpMessageConverter found for response type [java.util.Map<java.lang.String, java.lang.Object>] and content type [text/plain]

Actual Behavior

I am able to authenticate and authorize user without giving any scope but as soon as I add scope: https://www.googleapis.com/auth/contacts.readonly in application.yml, its throwing Could not extract response: no suitable HttpMessageConverter found for response type [java.util.Map<java.lang.String, java.lang.Object>] and content type [text/plain] exception.

Expected Behavior

It shouldnt have thrown the exception

Configuration

application.yml
oauth2:
client:
registration:
google:
client-id: <>
client-secret: <>
scope: https://www.googleapis.com/auth/contacts.readonly
provider:
google:
user-info-uri: https://www.googleapis.com/auth/contacts.readonly?alt=json

Version

I am using Spring boot 2.3.0.RELEASE and Spring security 5.3.2.RELEASE

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions