AuthenticationResult.CreateAuthorizationHeader Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates the content for an HTTP authorization header from this authentication result, so that you can call a protected API
public string CreateAuthorizationHeader ();
member this.CreateAuthorizationHeader : unit -> string
Public Function CreateAuthorizationHeader () As String
Returns
Created authorization header of the form "Bearer {AccessToken}"
Examples
Here is how you can call a protected API from this authentication result (in the result
variable):
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", result.CreateAuthorizationHeader());
HttpResponseMessage r = await client.GetAsync(urlOfTheProtectedApi);
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for