Authorization header removed after redirect
See original GitHub issueI’m not sure if this is supposed to be a feature because my other custom headers were preserved. Accept-Encoding is doubled on the second request as well.
First Request:
GET http://mydomain HTTP/1.1
X-Intel-Loglevel: DEBUG
Accept: application/json
x-request-id: cd013990-c68f-450a-afb3-f5d31fef08b7
Authorization: my authorization
User-Agent: RestSharp 104.1.0.0
Accept-Encoding: gzip, deflate
First Response:
HTTP/1.1 302 Moved Temporarily
Location: https://mydomain
Second Request:
GET https://mydomain HTTP/1.1
X-Intel-Loglevel: DEBUG
Accept: application/json
x-request-id: cd013990-c68f-450a-afb3-f5d31fef08b7
User-Agent: RestSharp 104.1.0.0
Accept-Encoding: gzip, deflate,gzip, deflate
Issue Analytics
- State:
- Created 10 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Beware of HTTP Redirects! - Muhammad Azeez
And when an HTTP call gets redirected, the Authorization header is removed as explained by the official docs. This behavior seems to be ......
Read more >Remove Authorization header upon cross-origin redirect
The Fetch standard has updated to remove Authorization header on cross origin redirects. Chrome should follow the spec change.
Read more >Authorization header is missing on redirect URL to the ...
The problem I am facing is that the Authorization header is not appended to the redirected URL, it is only appended to the...
Read more >Authorization Header not removed for 302 redirect URL by ...
Using HTTP request operation I am passing the token in the header along with the URL. After reaching the server it is getting...
Read more >Remove Authorization header upon cross-origin redirect
Remove Authorization header on cross origin redirects to scope a developer-controlled Authorization header to the origin of the initial request.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can just assign a CredentialsCache object to the request in the Authenticate method. Passing these credentials to a request indicates to the request that you allow them to be used, even for subsequent requests (redirects).
From this msdn article:
So a RestSharp BasicAuthenticator implementation could look like this:
You can either use the unfriendly-urls or implement the fix suggested by Haacked and me.