I have small client basically requests token from rest api and will do some calls over POST method.
For that purpose I need to do OAuth 2.0 authentication to the url. But I couldnt find how could I inject authorization data to the "request headers".
Header-Prefix = Bearer
Here is my code:
var token = "blablabalbal";
HttpRequest createExportJobRequest = httpRequestCreator.Create(exportJobUri);
createExportJobRequest.CookieContainer = cookieContainer;
createExportJobRequest.Method = HttpMethod.Post.Method;
//createExportJobRequest.Headers.Add("bearer");
createExportJobRequest.ContentType = "application/json";
createTokenRequest.AllowAutoRedirect = false;
createTokenRequest.Expect100Continue = false;
Please keep in mind I need solution only from rebex.net.httprequest
Thanks
I got too close and found solution need to use exaclty same line(5) at above code Header.Add
:
createExportJobRequest.Headers.Add("Authorization", $"Bearer {token}");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.