8000 [BUG] AuthorizationHeaderValueGetter ignored while using RefitSettings · Issue #1240 · reactiveui/refit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[BUG] AuthorizationHeaderValueGetter ignored while using RefitSettings #1240
Open
@mconca-kube

Description

@mconca-kube

If I use a custom HttpClient and custom RefitSettings, the AuthorizationHeaderValueGetter gets ignored and GetTokenAsync() is never called.

RestService.For<IAccountsClient>(
	new System.Net.Http.HttpClient()
	{
		BaseAddress = new Uri(apiIP + "Accounts"),
		Timeout = timeout
	}
	, new RefitSettings()
	{
		AuthorizationHeaderValueGetter = () => GetTokenAsync()
	});

This is the method in the Interface

[Headers("Authorization: Bearer")]
[Get("/EchoWithLogin")]
Task<string> EchoWithLoginAsync(string echoMessage);

Calling EchoWithLoginAsync does not add the token value to the header and the GetTokenAsync() method does not get called.

If insted I define the service as follows everything works fine, but I loose the timeout capability:

Accounts = RestService.For<IAccountsClient>(apiIP + "Accounts", new RefitSettings()
{
	AuthorizationHeaderValueGetter = () => GetTokenAsync()
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0