auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
59 stars 41 forks source link

Fetch AuthCode using the credential #336

Closed IKRAMULHAQ786 closed 11 months ago

IKRAMULHAQ786 commented 11 months ago

Checklist

Describe the problem you'd like to have solved

I have created login/signup screens in flutter and on successful login want to navigate the user to HomePage(webview screen). When the login is successful, The webview expects authorization code as a parameter, while i just have the Credentials object. So when i pass the access_token to the webview, it automatically redirects to the login page of the website. which is not the desired behavior. I just need the authCode, after i receive the credentials object. is there any way i can get that using this package.

Describe the ideal solution

It would be very helpful, if there is methdo which takes any parameter from the credentials object or from the Auth0 configuration and just provide the Authorization Code.

Alternatives and current workarounds

No response

Additional context

No response

Widcket commented 11 months ago

Hi @IKRAMULHAQ786, thanks for raising this.

I'm afraid I'm not following. Could you please provide more details?

I have created login/signup screens in flutter

Does this mean you're not using web auth, but that you've built your own native login/signup screens using the SDK's Authentication API client instead?

The webview expects authorization code as a parameter

I'm a bit confused. Could you expand more about this?

IKRAMULHAQ786 commented 11 months ago

Hi @Widcket thanks for quick reply.

Actually i am not using web auth, but i created native login and signup pages. I used auth0_flutter package to call the signup and login methods. I didn't create the auth0 account as i was given the configuration file which provided the domain and client id etc.

So i just developed these pages and called the auth methods.

On successful login i need to navigate the user to home page where webview is being used to display the website's dashboard. But when i pass the websites' url and access token to the webview, instead of showing me the dashboard webView automatically redirects me to the login page of website.

I have been told that i have to pass the authCode instead of accessToken to the website's url but i couldn't find authCode anywhere.

Auth0 is altogether new to me. Can you please guide me on this. Any help would be highly appreciated.

Widcket commented 11 months ago

Thanks for the clarification.

What you're trying to achieve is Single Sign On (SSO) between the website loaded on the webview and the native app. I'm afraid this is not possible here.

SSO is typically achieved by using Web Auth + system browser; that is, logging in with Web Auth drops a cookie that later on the website (opened on the system browser) can pick up to log the user in.

SSO is not possible if you're using the Auth API client instead of Web Auth (because there are no cookies involved), and if you're using a webview instead of the system browser to open the website (see also SFSafariViewController on iOS).

I'll close this one for now, as this is not an SDK issue.