Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Workforce tenants
External tenants (learn more)
We recommend that you call the acquireTokenSilent
method to acquire or renew an access token before calling a web API. After you have a token, you can call a protected web API.
Call a web API
Use the acquired access token as a bearer in an HTTP request to call any web API, such as Microsoft Graph API. For example:
var headers = new Headers();
var bearer = "Bearer " + access_token;
headers.append("Authorization", bearer);
var options = {
method: "GET",
headers: headers
};
var graphEndpoint = "https://graph.microsoft.com/v1.0/me";
fetch(graphEndpoint, options)
.then(function (response) {
//do something with response
})
Next steps
- Learn more by building a React Single-page application (SPA) that signs in users in the following multi-part tutorial series.
- Explore Microsoft identity platform single-page application code samples