i was looking for ways to bypass web redirect in sign in with google, i came across this idea;
- Use google_sign_in for native authentication (no web redirect).
- Send the obtained Google ID token to AppWrite for server-side verification.
- Get an AppWrite session without using OAuth redirects.
here is the code;
TypeScript
scopes: ['email', 'profile'],
serverClientId: 'YOUR_SERVER_CLIENT_ID', // Required for backend validation
);```
and
```Future<void> signInWithGoogle() async {
try {
// 1. Native Google Sign-In
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth = await googleUser!.authentication;
// 2. Extract ID Token (JWT)
final String? idToken = googleAuth.idToken;
if (idToken == null) throw Exception("No ID token received");
// 3. Authenticate with AppWrite
final Account account = Account(client);
final session = await account.createSession(
provider: 'google', // Must match AppWrite's provider
token: idToken, // Google's JWT token
);
print("Success! User ID: ${session.userId}");
} catch (e) {
print("Error: $e");
}
}```
is there a possibility of this working? @D5 @Steven
TL;DR
Use Google's native authentication to obtain the Google ID token and send it to AppWrite for server-side verification to bypass web redirect. The provided code should work for achieving this.Recommended threads
- is `account.get()` safe to be used in th...
I want to user's `id` for authentication. However, a while ago I was told in this server not to use `account.get()` and instead add user preferences for that us...
- [SOLVED] curl error Number: 6 — function...
Hello, I invested a lot of time in this error in a fresh install of appwrite 1.8.1 and lasted until fix, this if for helping anyone that can have the same weird...
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...