Hi everyone,
I’m currently working on integrating Okta authentication in my Flutter app using a WebView. I’ve set up the WebView to open the following URL for the OAuth2 authorization:
Here is a brief summary of what I’ve done so far:
- Created an Okta application and obtained the
client_id
. - Configured the redirect URI as
https://trial-8927900.okta.com%3A%2Fcallback
. - Set up the WebView in my Flutter app to load the authorization URL.
The WebView loads the Okta login page, and I’m successfully able to log in. However, when the redirection back to the app is supposed to happen using the specified redirect URI, I’m encountering an error. Below is the error I’m seeing:
code=_pm9ucd|55ojUwquOQvOUOAZzTFuPNDfYRKBI
5c67-47a1-ac7c-08d4bd049db6 could not be loaded
From the documentation, I understand that the code received in the redirect URL is the authorization code. My questions are:
- How do I properly handle the redirection and capture the authorization code in my Flutter app?
- Once I have the authorization code, how can I exchange it for an access token?
I’d appreciate any guidance or examples on how to:
- Capture the authorization code from the redirect URI.
- Make the appropriate request to exchange the authorization code for an access token.
Sorry for not able to put proper links and screenshots, since i am a new user and this forum doesnot allow to put links.
Thank you in advance for your help!