Auth0 Social connection - Wrong Http error status

I am currently using Auth0 for authentication in my SPA and I am storing the user_id generated by Auth0 in my own DB. The flow is the following:

  1. Email and password

When creating a user with email and password, either the user_id already exists in my DB and I can log the user in, either the user_id does not exist, which generates a 404 error status (NOT FOUND) and can lead to the creation of a new row in my DB.

enter image description here

  1. Google connection

Users can log in with Google authentication, in this case auth0 enables a connection with google. Here comes the error, instead of sending a 404 error it sends a 403 error (FORBIDDEN RESOURCE).

enter image description here

Did someone encounter the same problem? You can find my code below:

app.component.ts

  ngOnInit(): void {
    this.store.select('admin').subscribe(
      (adminState: AdminState) => {
        if (adminState.currentUserId && adminState.currentUserId !== this.currentUserId) {
          const uri = `users/${adminState.currentUserId}`;
          this.apiService.get(uri).subscribe(
            (user: User) => {
              this.store.dispatch(new AppActions.SetCurrentUser(user));
              this.router.navigate(['/']);
              this.currentUserId = adminState.currentUserId;
            },
            (error: HttpErrorResponse) => {
              if (error.status === 404) {
                console.log('Status code 404 - Resource not found');
                const newUser: UserCreateDto = {
                  clientId: adminState.currentClientId,
                  userId: adminState.currentUserId,
                };
                this.apiService.create('users', newUser).subscribe(
                  (u: User) => {
                    this.store.dispatch(new AppActions.SetCurrentUser(u));
                    this.router.navigate(['/']);
                    this.currentUserId = adminState.currentUserId;
                  }, (err) => {
                    console.log('Error creating User', err);
                    this.auth.logout();
                  }
                );
              } else if (error.status === 403) {
                console.log('Status code 403 - Forbidden resource');
                this.auth.logout();
              } else {
                this.auth.logout();
              }
            }
          );
        }
      }
    );
  }

Help would be greatly appreciated!

Hey @aboxho

As it has been more than a few months since this topic was opened and there has been no reply or further information provided from the community as to the existence of the issue we would like to check if you are still facing the described challenge?

We are more than happy to assist in any way! If the issue is still out there please let us know so we can create a new thread for better visibility, otherwise we’ll close this one in week’s time.

Thank you!

This topic was automatically closed after 6 days. New replies are no longer allowed.