Hi @sunnydev
Sorry about the late reply.
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!
Kind Regards,
Nik