React-native-aut0: authorize function from useAuth0 is giving null/undefined value. Unable to get accessToken token

const { authorize } = useAuth0();
const res = await authorize({ client_id: "test", audience: "test", scope: "openid profile email"},{ ephemeralSession: true });
console.log(res)
console.log(res?.accessToken)

After login, authorize is returning invalid response from which I get undefined as accessToken. This is happening intermittently.

Please help in resolving this.

Hi @sunnydev

Welcome to the Auth0 Community!

When you say that this happens intermittently, does that mean that for some users, you are able to return the access token after login and for some none?

Also, from what I can see in you code, the client_id parameter is usually handled by the Auth0Provider function imported in your application, you should be able to use it as an additional parameter but I would advise to let the Auth0Provider handle that.

Otherwise, this might happen due to the fact that some users already have a session with Auth0 and if you attempt to login with a user with an active session, the login request will get cancelled. As seen in your Github documentation for React Native, I would advise to call the clearSession() method to see if that fixes your issue. Also, make surer that you are passing in the right scopes and audience for your authorize call.

If you have any other questions, feel free to let me know!

Kind Regards,
Nik

Hi. Thanks for your reply.

This issue happens for all users but not every time. Sometimes it happens and sometimes it doesn’t.

Yes. I’m sending client_id from Auth0Provider too.

About clearing session, Yes I clear the session every time before i invoke authorize function.
Here is my session clearing code.

if (Platform.OS === "android") {
            await clearSession();
          } else {  
 await clearCredentials(); 
}

I found that clearSession will work only in android so that’s why above code looks like that.

Hi again,

Thanks for providing the additional info on the matter, I will keep looking into it and come back as soon as possible with an update!

Kind Regards,
Nik

Hi everyone,

I’m reaching out to understand the behavior of the Auth0 API in regard to user data updates. We’ve noticed an issue that’s causing occasional failures in our production process, and we’re wondering if it might be related to how Auth0 handles data for users.

Specifically, we’ve observed that:

  • For certain users, we’re seeing two rows with the same key attribute (e.g., user_id), but differences in dimension attributes like last_ip and login_count.
  • It seems that instead of updating an existing row, Auth0 might be adding a new row and then deleting the old one, leading to data discrepancies during our ETL process.
  • Per our requirement, only one entry is expected for one user session at a time. So, if there’s a limitation where a record can be inserted and then deleted within a few seconds or minutes rather than updating the existing record, it would explain this behavior. After running the process again, we only see the latest user session record.

My Questions:

  • Is this behavior of adding a new row and deleting the old one, rather than updating an existing row, a known issue or limitation in the Auth0 API?
  • Is this a design choice in how Auth0 handles user login or session data, and if so, is there a recommended way to handle or mitigate this situation?
  • Are there any best practices for ensuring consistency when working with user data in Auth0, especially if multiple rows are returned for the same user in quick succession, with differences in dimension attributes?

I appreciate any insights or suggestions the community can provide!