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
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour