Skip to content

Bug in Authorization Header construction #1677

@AlexKersjes

Description

@AlexKersjes

I am attempting to authenticate to an OAuth2 service. I am using this code:

[RestSharp.RestClient].Authenticator = new RestSharp.Authenticators.OAuth2.OAuth2AuthorizationRequestHeaderAuthenticator(token, "Bearer");

This way of Authentication attaches an Authorization header, however it is encoded, when it should not be, resulting in a header with the form of

Authorization: Bearer%20[token]

as it encodes the space in the header.

Manually attaching an Authorization header using

[RestSharp.RestRequest].AddHeader("Authorization", $"Bearer {token}", false)

works and resolves the issue, however the OAuth2 authentication procedure should work too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions