OppositeDragon
I have been having this issue for quite a while. This functionality was working fine on all flutter platforms, but then suddenly stopped working.
TL;DR
Title: Google Auth Problems
Developers have encountered issues with Google authentication in their Flutter app across multiple platforms. The functionality was previously working but stopped abruptly.
Solution:
1. In the `auth.html` file, ensure that authentication is completed and closed properly. The JavaScript code should send a post message to the Flutter app and close the window.
2. In the `androidManifest.xml` file, make sure the activity for the CallbackActivity has the correct data scheme specified according to your Flutter app's package name.
3. Check the Dart code for implementing Google sign-in. Make sure the necessary client and account configurations are set and the OppositeDragon
OppositeDragon
on flutter android
OppositeDragon
on flutter web
OppositeDragon
TypeScript
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 '';
}
}
OppositeDragon
for androidManifest
TypeScript
<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>
OppositeDragon
auth.html
TypeScript
<!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>
OppositeDragon
I would appreciate any help, on solving this. Thank you.
Recommended threads
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- apple exchange code to token
hello guys, im new here π I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...
- Our Appwrite organization is suspended
Please give support regarding this , no app is working now , please solve my issue and give support , no one is replying in message section or email.