-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Authorization header not being set when provided as [HeaderCollection] #1374
Comments
From your code sample it doesn't look like you're doing anything wrong, so it's surprising you say it's not working. I had a go at doing a reproduction of this and wrote some tests including one for this specific scenario but all the tests pass and when I inspect it via the debugger it works perfectly. |
Im having the same issue, except I have narrowed down mine to adding it to refit Settings
I have used this same code, slightly changed in the past, and it has worked, but this time it is not working. However, DrLeh way works for me. Could be that Task.FromResult, but again it has worked in the past. This is a .net core console application. EDIT: Added the async/await to the Header Task and still didnt see the headers in the client or the request |
I had the same problem and searching for a solution I stumbled over several posts, saying that Authorization header gets stripped, when a redirect happens.
With that I got an exception thrown, that a redirect happened.
Edit: fixed code formatting |
Same problem happening here |
I hit this same issue and discovered that I was receiving redirects from my target API thanks to @b1ubb0r 's comment above ☝🏻. I wanted to add that in my case I was being returned a 301-Moved Permanently because I had configured my endpoint to be |
It works for me. thanks!
|
My issue stated here: https://stackoverflow.com/questions/72172657/c-sharp-refit-client-is-not-sending-authorization-header
I'm using a C# client to have my services talk to one another via http.
I'm trying to send a Bearer token through the Authorization header, but according to the error message, it's not setting the AZ header in the request (see bottom). I've tried setting it through providing all headers, and using the [Authorize] attribute, and all the other methods as described in the readme.
Here is my Refit client api call definition:
However, I'm getting a 401, and looking at the Refit.ApiException that's thrown, the RequestMessage.Headers does not contain the Authorization header. When I debug the receiving server, i'm seeing that there is indeed no Authorization header set on the incoming request.
Here's how I'm registering my refit api
IPresentationsApi
. I'm not doing anything relating to auth in the DI configurationError shown here- you can see I get 401 because the AZ header is not set in the request as expected, even though the
pres_id
value is:And on the server-side I can also verify that there's no AZ header set
What am I doing wrong? How do I get it to send the AZ header?
Environment
The text was updated successfully, but these errors were encountered: