AuthenticationResult.CreateAuthorizationHeader Method

Definition

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