refreshTokenSetup

    0

    0

    The code creates a function that will refresh the authentication token after it has expired. It sets a delay so that the token will be refreshed every hour.

    export const refreshTokenSetup = (res) => {
      let refreshTiming = (res.tokenObj.expires_in || 3600 - 5 * 60) * 1000;
      const refreshToken = async () => {
        const newAuthRes = await res.reloadAuthResponse();
        refreshTiming = (newAuthRes.expires_in || 3600 - 5 * 60) * 1000;
        console.log(`newAuthRes`, newAuthRes);
    
        setTimeout(refreshToken, refreshTiming);
      };
    
      setTimeout(refreshToken, refreshTiming);
    };
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.