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);