Auth0 JS - signupAndAuthorize not logging in?

Hey! I have used signupAndAuthorize, it logs in the user and returns what is needed but when I invoke checkSession shortly after it returns with an error login_required

Hi @00dev,

Welcome to the Auth0 Community!

Please see these two links for what to do when the login_required error is returned:

Let me know if you have any additional questions!

Thanks,

Mary Beth

Hey, None of these seem to be my issue because the silent auth works perfectly after login it only happens with signupAndAuthorize

Hi @00dev,

Thanks for your reply! Can you kindly provide a screenshot or code snippet of the signupAndAuthorize implementation?

Thanks,

Mary Beth

Here you go, I am only using localstorage for test purposes.

webAuth.signupAndAuthorize(
        {
          connection: 'Username-Password-Authentication',
          email,
          password,
          user_metadata: { phone },
        },
        (err, result) => {
          if (err) {
            console.error('Signup error:', err);
            let errorMessage = err.message || err.description || 'Something went wrong, please try again later.';
            showErrorPopup(errorMessage);
            
            toggleButtonState(form, false);
            return;
          }

          console.log('Signup success:', result);

 
          const { accessToken, idToken } = result;

          if (!accessToken || !idToken) {
            console.error('Missing tokens in the signupAndAuthorize result.');
            alert('Signup succeeded, but login failed to generate tokens.');
            return;
          }
    
   
          localStorage.setItem('access_token', accessToken);
          localStorage.setItem('id_token', idToken);

          window.location.href = '/home';
        }
      );

Hey, Still waiting on a reply from the implementation.

Hi @00dev,

Apologies for the delay here.

When calling checkSession(), the browser must have third-party cookies enabled. Otherwise, checkSession() is unable to access the current user’s session (making it impossible to obtain a new token without displaying anything to the user). The same will happen if users have Safari’s ITP enabled.

Do you have third-party cookies enabled on your browser or have ITP enabled on Safari?

Thanks,

Mary Beth

Hey,

Yeah, I do have third party cookies enabled. checkSession(), works fine. Only facing the issue with signupAndAuthorize

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