auth0 / auth0-react

Auth0 SDK for React Single Page Applications (SPA)
MIT License
866 stars 252 forks source link

Facing Issue while Use getAccessTokenSilently #780

Open parth25 opened 2 months ago

parth25 commented 2 months ago

Checklist

Description

I am facing an issue while calling the getAccessTokenSilently method. The token is generated successfully, but the process does not move to the next step. Here is my code for your reference. If I remove this method, it works, but I need a new token to update my data. This issue only occurs when running the build version; it works correctly on my localhost.

const companyFormSubmit = (companyFormData: any) => {
    dispatch(
      companyRegisterPost({
        backendApi: backendApi,
        languageCode: i18n.language,
        name: companyFormData.companyName,
        billingAddress: companyFormData.billingAddress,
        city: companyFormData.companyCity,
        postalCode: companyFormData.companyZipcode,
        state: companyFormData.companyState,
        taxNumber: companyFormData.taxNumber,
        faviconIcon: companyFormData.logo,
        portalCountries: [companyFormData.selectedCompanyCountries]
      })
    ).then(async (response: any) => {
      if (response.meta.requestStatus === 'fulfilled') {
        await auth.getAccessTokenSilently({ cacheMode: 'off' }) // new token get
        props.setActiveStep(props.activeStep + 1)
      }
    })
  }

Reproduction

Step 1 : Register Custom Page

Additional context

No response

auth0-react version

2.2.4

React version

18.2.0

Which browsers have you tested in?

Chrome