Skip to content
Back

Google OAuth, Invalid argument (callbackUrlScheme)

  • 0
  • Flutter
  • Accounts
OppositeDragon
20 Jun, 2023, 22:00

Hello, I would like some help on this error please.

My app is already using email and password sign in, but I need to add Google sign in.

I use the same cliente and account objects across the app.

I have create the credentials on the google console.

The id and secret are set on appwrite cloud.

I am not sure why I am getting this exception.

This is the code:

TypeScript
Future<void> signInWithGoogle() async  {
    final account = ref.read(accountProvider);
    final result = await account.createOAuth2Session(
      provider: 'google',
    );
  }

I am targeting all available platforms in flutter, if there is something specific I need to do for each one, please mention it.

TL;DR
User is experiencing an error with Google OAuth in their app, specifically with the "Invalid argument (callbackUrlScheme)" exception. They have already set up the credentials on the Google console and Appwrite cloud. The user mentions using the same client and account objects across the app. They are targeting all available platforms in Flutter. - The user is debugging a macOS app but is still getting the exception. - The user has added all the platforms as indicated in the documentation, including following the web-specific instructions for OAuth2 redirect. - The project ID the user is using contains uppercase characters and they suspect it may be causing the issue. Another user suggests
Drake
20 Jun, 2023, 22:04

Yes, the success and failure urls are different depending on platform. For web, see https://github.com/appwrite/sdk-for-flutter/tree/master#web

OppositeDragon
20 Jun, 2023, 22:13

Could you please elaborate on this. I was debugging a mac app, still got the exception.

OppositeDragon
20 Jun, 2023, 22:15

I have added all the platforms as indicated on the docs.

OppositeDragon
20 Jun, 2023, 22:15
Drake
20 Jun, 2023, 22:52

the web section talked about what to do for the oauth2 recirect

Drake
20 Jun, 2023, 22:54

what's your project id?

OppositeDragon
20 Jun, 2023, 23:21

id: linearProgrammingApp

Drake
21 Jun, 2023, 01:23

i think the problem is the uppercase chars. could you see if doing setProject() with lowercase works?

Binyamin
21 Jun, 2023, 01:30
OppositeDragon
21 Jun, 2023, 02:48

Do i need to create a new project on appwrite where the id is all lower-case, or just change the name on the dart code

Binyamin
21 Jun, 2023, 02:49

Is this cloud or self hosted

OppositeDragon
21 Jun, 2023, 02:49

it is cloud

Binyamin
21 Jun, 2023, 02:49

Then you most recreate. You won't be able to change jt

Drake
21 Jun, 2023, 02:50

You can try changing what you pass into setProject

Binyamin
21 Jun, 2023, 02:50

Ohh interesting. Its not case sensitive?

Drake
21 Jun, 2023, 02:51

Maybe πŸ˜…

Binyamin
21 Jun, 2023, 03:09

Well, that's acutally good to know, My Appwrite instance is sets to utf8mb4_general_ci so it's actually case-insensitive, and my function run with upper case ids.

Binyamin
21 Jun, 2023, 03:09

And it should work also with the cloud.

OppositeDragon
21 Jun, 2023, 03:10

Just changing the string to lowercase on dart, apparently worked, because the browser window appeared and allowed me to authenticate, but I am still getting an exception. Not sure why

OppositeDragon
21 Jun, 2023, 03:11
TypeScript
    final account = ref.read(accountProvider);
    final result = await account.createOAuth2Session(
      provider: 'google',
    );
    final accountAfter = await account.get();
    debugPrint('google account: ${accountAfter.email}');
  }```
Binyamin
21 Jun, 2023, 03:11

Is this Android?

OppositeDragon
21 Jun, 2023, 03:11

Exception:

TypeScript
 AppwriteException: general_unauthorized_scope, User (role: guests) missing scope (account) (401) ```
OppositeDragon
21 Jun, 2023, 03:12

I need to make it work on all platforms, but was testing on macos, web still tell me that I need to correctly set up the redirection link

OppositeDragon
21 Jun, 2023, 03:15

Should I still re-create the appwrite project? or because the authentication window opened, is not necessary

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