Single-page application: Call a web API

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