I have been having this issue for quite a while. This functionality was working fine on all flutter platforms, but then suddenly stopped working.
on flutter android
on flutter web
Client client(ClientRef ref) {
return Client().setEndpoint('https://cloud.appwrite.io/v1').setProject('linearprogrammingapp');
}
Account account(AccountRef ref) {
final client = ref.watch(clientProvider);
return Account(client);
}
Future<void> signInWithGoogle() async {
final account = ref.read(accountProvider);
final result = await account.createOAuth2Session(
provider: 'google',
success: _successCallback(),
failure: _failureCallback(),
);
debugPrint('google siginresult: $result');
}
String? _successCallback() {
if (kIsWeb) {
final Uri? location = href == null ? null : Uri.parse(href!);
return '${location?.origin}/auth.html';
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return null;
case TargetPlatform.fuchsia:
return null;
case TargetPlatform.iOS:
return null;
case TargetPlatform.macOS:
return null;
case TargetPlatform.linux || TargetPlatform.windows:
return 'http://localhost:1001/auth/oauth2/success';
default:
throw UnsupportedError('Unsupported platform');
}
}
String? _failureCallback() {
switch (defaultTargetPlatform) {
default:
return '';
}
}
for androidManifest
<activity android:name="io.appwrite.views.CallbackActivity" android:exported="true">
<intent-filter android:label="android_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="appwrite-callback-linearprogrammingapp" />
</intent-filter>
</activity>
auth.html
<!DOCTYPE html>
<title>Authentication complete</title>
<p>Authentication is complete. If this does not happen automatically, please
close the window.</p>
<script>
window.opener.postMessage({
'flutter-web-auth-2': window.location.href
}, window.location.origin);
window.close();
</script>
I would appreciate any help, on solving this. Thank you.
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Appwrite Storage error 503s for automate...
I'm facing error 503s from Appwrite after about 5-6 seconds of making AI requests from my tool with images and files above 20MB (=> not inline base64 used, but ...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...