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
- Realtime doesn't seem to work with Table...
Hi, I am trying to connect my tables rows with realtime on my react website, it connects, but I dont get the rows when a row is being created. I tried with Chan...
- Guidance to safely upgrade Appwrite to l...
One of my old Flutter projects runs on a DO self-hosted Appwrite. Currently it's on appwrite: ^15.0.2 dart_appwrite: ^15.0.0 The app is live on the Play Stor...
- Resource limit error using API for proje...
Project ID: 67414182001dfe44c386 Endpoint: https://fra.cloud.appwrite.io/v1 Web Dashboard works fine, able to CRUD. But API return error ``` { "message": "...