getting the access token from mgt-login with globalProvider.getAccessToken. How do i get a refresh token?

89 views Asked by At

My frontend users are logging in with <mgt-login>

then i fetch their access token with

const msAccessToken = await Providers.globalProvider.getAccessToken({ scopes: this.scopes });

Now i send that token to the backend and make a graph client using '@microsoft/microsoft-graph-client' something like this.

const client = Client.init({
            authProvider: async (done) => {
                try {
                    done(null, delegatedAccessToken as string);
                } catch (err) {
                    console.log(' 6312', err);
                    done(err, null);
                }
            },
            debugLogging: true
        });
        return client;

problem

If the frontend user stays logged in for a long period of time then they trigger backend activity. the client cannot be made due to an expired token

Error: Access token has expired or is not yet valid

simply refreshing the frontend and trying the backend client again will work.

How can i refresh the access token on frontend or backend. Or at least how do i extend the expiration date?

0

There are 0 answers