-
Notifications
You must be signed in to change notification settings - Fork 177
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
Web auth receive token, but doesn't return to app #160
Comments
Might not be the same issue as we had but in our case on android, the issue was in the android manifest. Where the MainActivity is defined, there is a parameter called "android:launchMode". for us, it didn't redirect back until we set that to "singleTask" |
I managed to solve it in a different way:
<activity
android:name="com.linusu.flutter_web_auth.CallbackActivity"
android:exported="true">
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="com.codecentauri.nps"
android:host="oauth"
android:path="/callback" />
</intent-filter>
</activity> Note that the value of the
Future<void> authenticate() async {
final grant = OAuth2.AuthorizationCodeGrant(
clientId,
authorizationEndpoint,
tokenEndpoint,
secret: clientSecret,
);
final authorizationUrl = grant.getAuthorizationUrl(
Uri.parse(redirectUrl),
scopes: scopes,
);
try {
logger.i('Opening browser to authenticate the user.');
final result = await FlutterWebAuth.authenticate(
url: authorizationUrl.toString(),
callbackUrlScheme: 'com.codecentauri.nps',
);
final code = Uri.parse(result).queryParameters['code'];
if (code == null) {
throw Exception('Authorization code not found.');
}
final client = await grant.handleAuthorizationResponse({'code': code});
await _saveCredentials(client.credentials);
_client = client;
} on OAuth2.AuthorizationException catch (e) {
logger.e('Error during authentication: $e');
} on Exception catch (e) {
logger.e('Unknown error during authentication: $e');
}
} Ensure the
Extra: <uses-permission android:name="android.permission.INTERNET"/> |
After successful authorization , i must close browser by myself. On iOS it works normal, and app open by itself
The text was updated successfully, but these errors were encountered: