Auth0 Home Blog Docs

CompactToken parsing failed with error code: 80049217 when using passport library to access Microsoft Graph API

I am using ‘passport-azure-ad-oauth2’ npm module, to get an access token, which I could then pass to the MS Graph API.

passport.use(new AzureAdOAuth2Strategy({
    clientID: process.env.OUTLOOK_CLIENT_ID,
    clientSecret: process.env.OUTLOOK_SECRET,
    callbackURL: '/auth/outlook/callback',
    function (accesstoken: any, refresh_token: any, params: any, profile, done) {'Completed azure sign in for : ' + JSON.stringify(profile));'Parameters returned: ' + JSON.stringify(params));
        const decodedIdToken: any = jwt.decode(params.id_token);'Outlook Access Token:' + accesstoken);'Decoded Token: ' + JSON.stringify(decodedIdToken, null, 2));

        process.env['OUTLOOK_ACCESS_TOKEN'] = accesstoken;
        // add new user with token or update user's token here, in the database


And then, using @microsoft/microsoft-graph-client’ npm module, to fetch Calendar events from the Graph API as follows:

try {
    const client = this.getAuthenticatedClient(process.env['OUTLOOK_ACCESS_TOKEN']);
    const resultSet = await client
                .api('users/' + userId + '/calendar/events')
                .get();, null, 2));
} catch (err) {

getAuthenticatedClient(accessToken) {'Using accestoken for initialising Graph Client: ' + accessToken);
    const client = Client.init({
        // Use the provided access token to authenticate requests
        authProvider: (done) => {
            done(null, accessToken);

    return client;

However, however, using the accessToken provided on Successful Login, I get the following error : CompactToken parsing failed with error code: 80049217

Any suggestions what am I doing incorrectly ???

Hi there @voodoorapter014, I apologize for the delay in response.

Are you using Onedrive? They appear to have a open Github issue for something related to this:

Please let me know if you are still battling this challenge. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.