Back

Not returning to Flutter app after OAuth login

  • 0
  • Self Hosted
  • Flutter
  • Auth
THE-E
16 Jun, 2024, 19:26

My Flutter app is currently not getting redirected back to my app once the OAuth login was successful.

I am using the Google OAuth login as followed:

TypeScript
await _account.createOAuth2Session(
  provider: OAuthProvider.google,
  scopes: [
    'https://www.googleapis.com/auth/userinfo.email',
    'https://www.googleapis.com/auth/userinfo.profile',
  ],
);

The strange thing is, that if I cancel the login, that the login in the app usually works fine. (A restart of the app alwasy works fine).

I have a self-hosted Appwrite backend with the following structure: Appwrite: Version 1.5.5 Flutter SDK: 12.0.4 Hosted on: baas.example.com using digitalocean.com Under Custom Domains, there is nothing listed. Trying to add anything does not work.

I am using nginx proxy manager to reverse proxy to baas.example.com and create its certificate.

Am I missing a necessary configuration? Do I have to add success and failure values? If so what are the values?

In the browser (web) I do get the following permanent redirect to: https://baas.example.com/auth/oauth2/success?project=*****&domain=.baas.example.com&key=a_session_630f8d82d13133b826cc&secret=***#

My website is hosting the app is using the domain app.example.com.

TL;DR
Issue: Flutter app not redirecting back after successful OAuth login with Google. Problem: Missing necessary configurations for OAuth success and failure values. Solution: Add `success` and `failure` values in the OAuth configuration. Update the OAuth redirect URI to reflect the correct custom domain for the Flutter app (app.example.com) and handle the authentication flow accordingly in the app.
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