Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AddRefitClient doesn't use the AuthorizationHeaderValueGetter #689

Closed
Elfocrash opened this issue Jun 13, 2019 · 7 comments · Fixed by #861
Closed

[BUG] AddRefitClient doesn't use the AuthorizationHeaderValueGetter #689

Elfocrash opened this issue Jun 13, 2019 · 7 comments · Fixed by #861

Comments

@Elfocrash
Copy link

Describe the bug
If I use the AddRefitClient to register my client then the AuthorizationHeaderValueGetter isn't used.

I have the following interface and the following settings:

[Headers("Authorization: Bearer")]
public interface ISomeApi
{
    [Get("/users/{user}")]
    Task<ApiResponse<User>> GetUser(string user);
}

var refitSettings = new RefitSettings
{
    AuthorizationHeaderValueGetter = () => Task.FromResult("AuthKey")
};

If i call RestService.For<ISomeApi>("https://api.test.com", refitSettings) then my call is properly populated with the Authorization header having a value Bearer AuthKey.

However if I use the same ISomeApi interface using the AddRefitClient like this services.AddRefitClient<ISomeApi>(refitSettings); then the Authorization header's value is Bearer. The getter is never invoked to set the value.

Expected behavior
Both RestService.For and AddRefitClient should be utilizing the settings in the same way and the header should be populated.

Environment

  • OS: Windows 10 Pro
  • Version 10.0.17134
  • Device: PC
@Elfocrash Elfocrash added the bug Something isn't working label Jun 13, 2019
@Styxxy
Copy link
Contributor

Styxxy commented Jun 13, 2019

Might be similar like #574 , because of the HttpClientFactory. To be determined though.

@Elfocrash
Copy link
Author

After some debugging it looks like the AddRefitClient path completely ignores the Handler selection

@endeffects
Copy link

endeffects commented Aug 25, 2019

@onovotny @Elfocrash Any progress here?

@Elfocrash
Copy link
Author

I had to do some DI hack locally to get this to work on my project but no actual fix yet. Both AuthorizationHeaderValueGetter and the other requestMessage one are not working.

@endeffects
Copy link

@onovotny Could you please have a look into this? Refit should be able to override this HttpClientFactory settings especially for authorization.

@clairernovotny
Copy link
Member

PR's with related unit tests are welcome!

I've been busy and haven't had time to look into this.

@clairernovotny clairernovotny added up-for-grabs bug and removed bug Something isn't working labels Sep 22, 2019
@clairernovotny
Copy link
Member

Fixed by #861

@lock lock bot added the outdated label Jun 24, 2020
@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants