Back

[SOLVED] Getting a bug while redirecting to app after social auth in Flutter

  • 0
  • Android
  • Flutter
  • Accounts
ZiaChoudhary
30 Sep, 2023, 19:17

Appwrite is showing a weird behavior after redirecting from social auth. It is giving me option to pick an app rather than auto redirecting to the app. Here is my android manifest code; <activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity" android:exported="true"> <intent-filter android:label="flutter_web_auth_2"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="appwrite-callback-65181fc368c9ae7e585l" /> </intent-filter> </activity> Kindly have a look into it why its behaving like this. In Actual case it should auto redirect to the app.

TL;DR
The user was having a bug while redirecting to their app after social authentication in Flutter. They provided their code and found out that the SDK version they were using was not compatible with the version of Appwrite they were on. They needed to downgrade the SDK version and read the readme. After doing this, they were able to redirect properly but encountered a new problem with an exception. They posted the code causing the exception and mentioned that it occurred when calling the `_getAccount()` function. Another user suggested deleting the playground app, and another user mentioned that the problem was happening because there were two apps with the same URL scheme configured, causing Android
Drake
30 Sep, 2023, 19:20

This happens because you have two apps with the same url scheme configured so Android doesn't know which app to redirect to

Drake
30 Sep, 2023, 19:20

How about you delete the playground app?

ZiaChoudhary
30 Sep, 2023, 19:33

@Steven yes now app is getting redireted properly but creating another problem: after calling createOAuth function i am getting this exception: Exception has occurred. _TypeError (type 'Null' is not a subtype of type 'List<dynamic>') my code for createOAuth2Session is ```Future<void> logInWithGoogle() async { try { await _accountProvider.createOAuth2Session( provider: 'google', ); _getAccount();

TypeScript
} on AppwriteException catch (_) {
  rethrow;
} catch (error, stackTrace) {
  Error.throwWithStackTrace(LogInWithGoogleFailure(error), stackTrace);
}

} and my _getAccount() code is as follows: _getAccount() async { try { final user = await _accountProvider.get(); if (user.email.isEmpty) { print('user email is empty'); } else { print('user email is not empty'); } } on AppwriteException catch (error) { print(error.message); } }``` Exception is being caught while calling _getAccount() function

Drake
30 Sep, 2023, 19:42

What version of the Appwrite Flutter SDK are you using and what version of Appwrite are you on?

ZiaChoudhary
30 Sep, 2023, 19:44

@Steven appwrite flutter sdk -> appwrite: ^11.0.0 while appwrite self hosted Version 1.3.8

Drake
30 Sep, 2023, 21:05

That SDK version is not compatible with the version of Appwrite you are on. Downgrade and read the readme

ZiaChoudhary
1 Oct, 2023, 06:05

@Steven Yes it solved the problem. But i have a concern what if i have two apps in the same project, then how can I avoid app selection issue while redirecting from social auth.?

Drake
1 Oct, 2023, 06:47

That's a limitation at the moment

ZiaChoudhary
1 Oct, 2023, 06:48

@Steven Ohhh, are there any plans to remove this limitation in near future?

Drake
1 Oct, 2023, 15:32

No plans at the moment. I think this is the related issue: https://github.com/appwrite/appwrite/issues/1515

Make sure you πŸ‘ it

ZiaChoudhary
3 Oct, 2023, 12:59

[SOLVED] Getting a bug while redirecting to app after social auth in Flutter

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more