Office-ExcelAddIn token expires
Hi,
I have developed Office-ExcelAddIn using Angular. I am using OfficeRuntime.auth.getAccessToken() to get the taken for api authentication. After 87min the token expires and ExcelAddIn stops working. If I try to use the getAccessToken() method after 87 minutes, I get an exception.
Even If try to call getAccessToken() before token expiry to refresh the token , I am still getting the exception.
is there a way to refresh the token seamlessly without the user having to close the ExcelAddIn and open again ?
Sample method for getting the token
public async getUserToken(): Promise<User> {
try {
console.log("getUserToken -> Start");
const tokenData = await OfficeRuntime.auth.getAccessToken({
allowSignInPrompt: false,
forMSGraphAccess: true,
});
const parts = tokenData.split(".");
const userToken = JSON.parse(atob(parts[1]));
this.user = {
name: userToken.name,
email: userToken.preferred_username,
token: tokenData,
};
} catch (error: any) {
console.error(error);
throw new Error("unable to get token");
}
return this._user;
}