Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which redirect url should I use? #40

Open
luancaius opened this issue May 4, 2024 · 5 comments
Open

Which redirect url should I use? #40

luancaius opened this issue May 4, 2024 · 5 comments

Comments

@luancaius
Copy link

Hello, first, congrats on the project, it makes the user experience with azure ad b2c much better.
I was trying to setup on my app, but I'm having trouble with the redirect url.
For example if my bundle id is com.example.mobile and the redirect url on azure ad b2c for ios is msauth.com.example.mobile://auth, what should I replace that as redirect url?
I tried to create a SPA redirect url on azure ad b2c, put a random url and it redirected after login, but I need to make it come back to the app instead of visiting another url.
Any ideas on how to fix this? Thanks!

@mohanajuhi166
Copy link
Collaborator

@luancaius does this work for you ?

final aadB2CRedirectURL = 'customScheme://your_bundle_id/auth';

@mohanajuhi166
Copy link
Collaborator

have a look here: #23

@luancaius
Copy link
Author

@mohanajuhi166 I tried the following scenarios:
Test 1 - Created web redirect on azure with redirect url as "https://bundle_id/auth" (set the same url on flutter)
I also update my AndroidManifest.xml, adding this:

<intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="https" android:host="<bundle_id>" android:pathPrefix="/auth" />
</intent-filter>

On IOS I got a null exception:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0      ADB2CEmbedWebViewState.initState.<anonymous closure> (package:aad_b2c_webview/src/presentation/aad_b2c_webview.dart:94:63)
#1      WebKitWebViewController._webView.<anonymous closure>.<anonymous closure> (package:webview_flutter_wkwebview/src/webkit_webview_controller.dart:299:32)
<asynchronous suspension>

and on Android I got Webpage not available with the token response and net::ERR_NAME_NOT_RESOLVED.
I wonder if I have to use any deep link here to redirect to my main page.

Test 2 - Same as 1 for url "https://.b2clogin.com/oauth2/nativeclient"
Didnt work at all, even updating the intent filter.

What I have working is using fluuter_appauth 6.0.6 and the following settings on azure and flutter:
IOS redirect url "msauth.<bundle_id>://auth"
Android redirect url "msauth://<bundle_id>/signature_hash"

Do I need to delete the other redirects and leave just the Web one?
Also if it's not a lot of work, an example using duende identity like https://pub.dev/packages/flutter_appauth/example would be very helpful.
Thank you!

@mohanajuhi166
Copy link
Collaborator

@luancaius at the moment , the web redirect should work so you can try deleting those . Will look into the implementation by https://pub.dev/packages/flutter_appauth/example and implement it.

@luancaius
Copy link
Author

Tried deleting all others, and it was loading the login page, but still not working. My redirect url was https://bundle_id/auth. On IOS the login didn't redirect and on Android I got Webpage not available with the token, like before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants