Closed rehusevych closed 1 year ago
login in app using
firebase_auth
with keycloak
@rehusevych If you simply using only firebase_auth
stand-alone without third party and try the steps you mentioned in description, does it still give you the reported error or not ?
login in app using
firebase_auth
with keycloak@rehusevych If you simply using only
firebase_auth
stand-alone without third party and try the steps you mentioned in description, does it still give you the reported error or not ?
I create new project without third party packages and firebase_auth with the same firebase project start working fine without any errors. Maybe you have any ideas what could be the reason why firebase_auth doesn't work only on android with third party packages?
Good to know that without third party packages, there's no issue. Looking at your pubspec.yaml, I see lot of external plugins you are using and there could be a conflict between one of them with firebase_auth
which you'll probably need to find out, because with the error, it is tough to tell what exactly could be causing it.
It could also be that, you are probably trying to use firebase core before the FirebaseApp initialization, so make sure you are initializing the FirebaseApp first and properly before using any of other services.
I will go ahead and close the issue for now, as it is not related to firebase_auth, but could be due to external dependency conflict or the way you are initializing the app for which you can take a look at documentation and confirm. If you disagree or are able to replicate this error only using firebase_auth
consistently, write in comments and I'll reopen it.
Good to know that without third party packages, there's no issue. Looking at your pubspec.yaml, I see lot of external plugins you are using and there could be a conflict between one of them with
firebase_auth
which you'll probably need to find out, because with the error, it is tough to tell what exactly could be causing it.It could also be that, you are probably trying to use firebase core before the FirebaseApp initialization, so make sure you are initializing the FirebaseApp first and properly before using any of other services.
I will go ahead and close the issue for now, as it is not related to firebase_auth, but could be due to external dependency conflict or the way you are initializing the app for which you can take a look at documentation and confirm. If you disagree or are able to replicate this error only using
firebase_auth
consistently, write in comments and I'll reopen it.
Hi again, today I tried to change signInWithCredential
to signInWIthEmailAndPassword
and in this way everything works good on Android with all third party packages. signInWithCredential
works correctly on iOS, but on Android thrown this exception [firebase_auth/unknown] null
. Now I'm sure, that problem isn't due to use third-party packages and not due to FirebaseApp initialization before using firebase_core
Hi @darshankawar, having same issue
@rehusevych @yura2000 Would be great if you could provide us a minimal reproducible code sample that shows the reported error, so that it'll help us to make this issue actionable.
@rehusevych @yura2000 Would be great if you could provide us a minimal reproducible code sample that shows the reported error, so that it'll help us to make this issue actionable. yeah, of course, here is a code sample:
TaskEither<AuthFailure, AuthUserData> signInWithSSO({ required void Function(bool) onLaunched, }) { urlLauncher(String url) async { if (await canLaunchUrlString(url)) { await launchUrlString(url); } else { throw 'Could not launch $url'; } }
return TaskEither.tryCatch(
() async {
final uri = Uri.parse(keycloakUrl);
final scopes = List<String>.of([
'profile',
'openid',
'offline_access',
]);
const port = 4200;
final issuer = await Issuer.discover(uri);
final client = Client(issuer, keycloakClientId);
final authenticator = Authenticator(
client,
scopes: scopes,
port: port,
urlLancher: urlLauncher,
);
final auth = await authenticator.authorize();
unawaited(closeInAppWebView());
final token = await auth.getTokenResponse();
final info = await auth.getUserInfo();
if (token.accessToken != null) {
try {
final provider = OAuthProvider(oAuthKeycloak).credential(
idToken: token.idToken.toCompactSerialization(),
);
await FirebaseAuth.instance.signInWithCredential(provider);
} catch (e) {
//here exception thrown
throw Exception(e);
}
await _store.persistAccessToken(token.accessToken!);
}
if (token.refreshToken != null) {
await _store.persistRefreshToken(token.refreshToken!);
}
return AuthUserData(
token: token,
email: info.email,
given_name: info.givenName,
family_name: info.familyName,
);
},
AuthFailure.ssoUnavailable,
);
}
@rehusevych Sorry but above code is not complete and we can't use it directly as it seems to contain custom implementation, that' why we requested earlier to provide a minimal reproducible code sample without third party plugins that we can directly use to verify this issue further.
@rehusevych Sorry but above code is not complete and we can't use it directly as it seems to contain custom implementation, that' why we requested earlier to provide a minimal reproducible code sample without third party plugins that we can directly use to verify this issue further. Sorry for a long response, I created a new public repository with minimal reproducible code sample. Here is a link to repository: repository link
Looking at the repo code you provided above, you seem to be providing a custom OAuthProvider in keycloak which I am not sure could be leading to the behavior you are seeing.
Also, I see other custom (third party) implementations using openid, so it could be a combination of that.
Can you try same scenario using any other third party library such as https://github.com/amrfarid140/firebase_auth_oauth and see if using it, you still get same error or not ?
Also, I would still like a narrowed down example with only using firebase_auth
and url_launcher
and see if it still triggers same error or not. You may also try to run in verbose mode and see if you get any additional logs in the console for the error.
Looking at the repo code you provided above, you seem to be providing a custom OAuthProvider in keycloak which I am not sure could be leading to the behavior you are seeing. Also, I see other custom (third party) implementations using openid, so it could be a combination of that. Can you try same scenario using any other third party library such as https://github.com/amrfarid140/firebase_auth_oauth and see if using it, you still get same error or not ? Also, I would still like a narrowed down example with only using
firebase_auth
andurl_launcher
and see if it still triggers same error or not. You may also try to run in verbose mode and see if you get any additional logs in the console for the error.
Hi, I'm tried to use firebase_auth_oauth package, but but it does not support auth through keycloak, so I'm tried to use https://pub.dev/packages/openidconnect but still getting the same error. Verbose logs do not write anything
I am not sure about usage, integration and support of keycloak with firebase_auth
and that seems to be the reason of the error and since it is third party, I suggest you to reach out to dedicated plugin repo.
Closing for now, as this doesn't seem to be firebase_auth plugin issue. If you disagree, write in comments and I'll reopen it.
I am not sure about usage, integration and support of keycloak with
firebase_auth
and that seems to be the reason of the error and since it is third party, I suggest you to reach out to dedicated plugin repo. Closing for now, as this doesn't seem to be firebase_auth plugin issue. If you disagree, write in comments and I'll reopen it.
Sorry, but if keycloak is not supported by firebase_auth, why on iOS everything works good? You have any idea about this?
I am not sure about usage, integration and support of keycloak with
firebase_auth
and that seems to be the reason of the error and since it is third party, I suggest you to reach out to dedicated plugin repo. Closing for now, as this doesn't seem to be firebase_auth plugin issue. If you disagree, write in comments and I'll reopen it.
Hi, sorry for stealing your time, but I really need a solution to this problem. I've tried a lot of things, but I still can't find a solution
Reopening and for team's insights on this use case.
/cc @Lyokone
@darshankawar, @Lyokone any updates?
@darshankawar, @Lyokone Still an issue! Can't go live to the stores. Please, help!
There are no updates. We need a reproducible sample, ideally a GitHub repo where I only have to setup my own Firebase project on the app. Please also include any additional configurations steps that might be necessary for third party setup. This is the quickest way to get our attention and a fix for the issue. Thanks.
Hey @rehusevych. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@rehusevych if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Bug report When I tried to login in app using
firebase_auth
with keycloak and after callingsignInWithCredential()
the following exception is thrown:[firebase_auth/unknown] null
This exception thrown only on Android(on iOS everything works fine) and in debug console there is no explanation of this error.
Additional context I using
firebase_auth: ^4.0.1
Flutter doctor
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below: