You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Any complete on how to use AuthorizationHeaderValueGetter #573
I first tried injecting IMyApi into one of my service classes, but the header is not extenden with the token (nor is the Func passed to the settings invoked). I also tried directly gettings the service using
Even with 4.7.9 I can't get this to work in ASP.NET Core. The docs on this topic are just about useless. Anyone getting this to actually work?
Thanks to the suggestions above, I did get it to work without problems. I would submit the example, but I don't have access to the code within the next two weeks.
I also can't get this to work in 4.7.9 when using in conjunction with Refit.HttpClientFactory, it only works when using the regular refit RestService.For<T>(string hostUrl, RefitSettings settings) as commented previously. As a workaround I was passing Authorization as parameter individually to each API method call, but this is a pain. Not sure about method above for calling AddHttpMessageHandler<AuthorizationMessageHandler>(); as AuthorizationMessageHandler doesn't appear to be something that is OOTB? Closest match is a handler which is internal to Refit assembly.
Well I'm glad that I'm not the only one that can't make this work as intended, as well as not being able to make sense of the docs. Rather than show a sample they show classes that one of which is internal. So for hours I'm looking at this like "do I copy and paste this class into my project?"
I will use the proposed work around, but it seems like this issue should be reopened as the commit didn't seem to actually fix this, unless we're all just using it wrong?
Edit: Hmm.. RestService.For doesn't seem to work with HttpClientFactor, unless I'm missing something there, you can't configure the client. Meanwhile the other work around using
services.AddRefitClient() .ConfigureHttpClient(c => c.BaseAddress = new Uri("...")) .AddHttpMessageHandler(); doesn't work because of the internal class. Or are you just pulling this one in manually?
Hi All, Here is the Startup class, where I configured Refit with HttpMessageHandler.
The repository is meant to work with the Refit library (4.7.9).
For me, it works and I can use/accept this workaround.
I hope it helps you.
Ah thanks, you're just pulling that whole handler in. Which honestly is probably what I need to do anyways since I don't think I can access the current httpcontext, which is where my access token is, directly in that func anyways. Meanwhile, if anyone has any example of just integrating this with Auth0 that would be super rad ;)
Activity
19balazs86 commentedon Jan 11, 2019
Same problem :(
The AuthorizationHeaderValueGetter is not called by the library, if I use the IServiceCollection.AddRefitClient.
RestService.For works fine.
ahmedalejo commentedon Jan 22, 2019
Using the following will work:
RestService.For<T>(string hostUrl, RefitSettings settings)while others will not19balazs86 commentedon Jan 22, 2019
services.AddRefitClient<ISomething>() .ConfigureHttpClient(c => c.BaseAddress = new Uri("...")) .AddHttpMessageHandler<AuthorizationMessageHandler>();For me this solution works well.
Merge pull request #629 from benjaminhowarth1/master
natelaff commentedon Jul 15, 2019
Even with 4.7.9 I can't get this to work in ASP.NET Core. The docs on this topic are just about useless. Anyone getting this to actually work?
ericontilt commentedon Jul 15, 2019
Thanks to the suggestions above, I did get it to work without problems. I would submit the example, but I don't have access to the code within the next two weeks.
19balazs86 commentedon Jul 15, 2019
Thanks in advance. (I still can use the solution, which I wrote until the official one)
breenbob commentedon Jul 15, 2019
I also can't get this to work in 4.7.9 when using in conjunction with
Refit.HttpClientFactory, it only works when using the regular refitRestService.For<T>(string hostUrl, RefitSettings settings)as commented previously. As a workaround I was passing Authorization as parameter individually to each API method call, but this is a pain. Not sure about method above for callingAddHttpMessageHandler<AuthorizationMessageHandler>(); as AuthorizationMessageHandlerdoesn't appear to be something that is OOTB? Closest match is a handler which is internal to Refit assembly.natelaff commentedon Jul 15, 2019
Well I'm glad that I'm not the only one that can't make this work as intended, as well as not being able to make sense of the docs. Rather than show a sample they show classes that one of which is internal. So for hours I'm looking at this like "do I copy and paste this class into my project?"
I will use the proposed work around, but it seems like this issue should be reopened as the commit didn't seem to actually fix this, unless we're all just using it wrong?
Edit: Hmm.. RestService.For doesn't seem to work with HttpClientFactor, unless I'm missing something there, you can't configure the client. Meanwhile the other work around using
services.AddRefitClient() .ConfigureHttpClient(c => c.BaseAddress = new Uri("...")) .AddHttpMessageHandler(); doesn't work because of the internal class. Or are you just pulling this one in manually?
19balazs86 commentedon Jul 15, 2019
Hi All,
Here is the Startup class, where I configured Refit with HttpMessageHandler.
The repository is meant to work with the Refit library (4.7.9).
For me, it works and I can use/accept this workaround.
I hope it helps you.
natelaff commentedon Jul 15, 2019
Ah thanks, you're just pulling that whole handler in. Which honestly is probably what I need to do anyways since I don't think I can access the current httpcontext, which is where my access token is, directly in that func anyways. Meanwhile, if anyone has any example of just integrating this with Auth0 that would be super rad ;)