Skip to content

Unable to set User-Agent on oauth2-client causes issues with some oauth2 servers. #4958

@Woodham

Description

@Woodham

Summary

Not sure if this would be considered a bug or feature request, however it is causing issues trying to authenticate with an oauth2 server.

When using the oauth2-client, it's not possible to set the User-Agent for the requests made to authenticate and retrieve the user info. This causes issues for some oauth2 servers - specifically those behind Cloudflare, which blocks requests without a user-agent.

The specific server I'm having trouble with is Discord.

If I replace NimbusAuthorizationCodeTokenResponseClient.java and NimbusUserInfoResponseClient.java to add a User-Agent header in the requests, everything works as expected. (Any user agent works, as long as it's not blank).

Actual Behavior

Without overriding the classess to add a User-Agent, I get a 403 for both of those requests.

Expected Behavior

I am able to complete the oauth2-client flow.

Configuration

I'm using Spring Boot 2.0 (latest snapshot) Autoconfiguration.

Version

Spring Security 5, specifically for oauth2-client.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions