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. Once you have a token, you can call a protected web API.

Call a web API

JavaScript

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
        }

Angular

As mentioned in the acquiring tokens section, the MSAL Angular wrapper leverages the HTTP interceptor to automatically acquire access tokens silently and attach them to the HTTP requests to APIs.

Next steps