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!
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!
Just to confirm, is the user logged in successfully whenever the accessToken is returned as undefined? If so, it might be a matter of the console log running prior to the accessToken being returned through the authorize call.
You could try to encapsulate the authorize() in a try{}....catch{} block in order to see if the call is executed successfully or what is the exact error returned.
Otherwise, the code you have presented should execute just fine. I would recommend to review our documentation regarding React Native Quickstart.
Also, if you are using refresh tokens for your application, you might be missing the offline_access scope. I would recommend to review this community post regarding the matter and if you do not use refresh tokens, to read this article on Github in order to see how to implement them.
Alternatively, you can also try using getTokenSilently() or getAccessTokenSilently().
Hope this helps! Let me know if you have any other questions or updates on the matter!