Back

Error OAuth2 / flutter

  • 0
  • Flutter
  • Accounts
Sabit
27 Mar, 2023, 14:26

Ok

TL;DR
User is experiencing an error with OAuth2 in Flutter. They are asking how to update the phone number without a password after logging in with OAuth2. There is a discussion about server-side problems and rolling back versions of the project. Eventually, it is discovered that the project ID cannot contain an underscore character and needs to be renamed through MariaDB. There is a suggested solution for running a createOAuth2Session function. The user confirms that registration via email works.
Sabit
27 Mar, 2023, 14:34

Here is the function for authorization via OAuth2

Binyamin
27 Mar, 2023, 14:40

It's seem like the value of jetservice_server is not the same is the value you've entered when you initialized your client

Is this how your client creation looks?

TypeScript
Client client = Client()
    .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
    .setProject('jetservice_server');
Sabit
27 Mar, 2023, 14:45
Sabit
27 Mar, 2023, 14:46

But registration via email. works.

Binyamin
27 Mar, 2023, 14:55

Try to run it as follow

TypeScript
account.createOAuth2Session(
    provider: 'google',
    success: 'appwrite-callback-jetservice_server://',
    failure: 'appwrite-callback-jetservice_server://',
  )
Binyamin
27 Mar, 2023, 14:56

I think that because you're using a service container the createOAuth2Session is unable to get your project id to created the success and failure urls

Sabit
27 Mar, 2023, 15:00

OK thanks! I'm going to try now

Sabit
27 Mar, 2023, 15:02

There is no change. Same error

Binyamin
27 Mar, 2023, 15:09

OK, I've found the issue your project ID can't contain the underscore _ character if you want to use OAuth2 You can use the dash - if you want That mean you'll have to recreate the project or rename it thorough direct access to the MariaDB

You can see more details here https://github.com/ThexXTURBOXx/flutter_web_auth_2#troubleshooting-callbackurlscheme

This is the package on which the OAuth2 login is running on

Sabit
27 Mar, 2023, 15:15

How to rename a project via MariDB? Is it possible to rename a project via env file? Because this project has already started. We just wanted to add Google and Apple authentication.

Binyamin
27 Mar, 2023, 15:18

It's a bit complex matter You'll have to tunnel to your MariaDB server using something like DataGrip you can see some details here https://discord.com/channels/564160730845151244/1088290647036923976/1088292555688530010 Be sure to backup everything before performing any action.

The changes will require you to change the project id in many places in the database I do recommend to check building some utility and copy all the data to a newly created project

Sabit
27 Mar, 2023, 15:19

Or can it be renamed via docker-compose.yml?

Binyamin
27 Mar, 2023, 15:19

No, This data is only in the database

Sabit
27 Mar, 2023, 15:23

I can't even create a new project. I wanted to create a new project in parallel and copy the entire collection from there. Interesting

Binyamin
27 Mar, 2023, 15:24

Weird

Sabit
27 Mar, 2023, 15:33

Updated the latest version more precisely to version 1.2. On the previous version, I tried to create two or more projects, and everything worked without problems? A new problem has been discovered that should solve it. What a pity

Sabit
27 Mar, 2023, 15:44

rolled back to version 1.0.3. And in parallel the second project was created

D5
27 Mar, 2023, 16:30

It seems to be more a server-side problem. Maybe the server instance got corrupted

Drake
27 Mar, 2023, 17:04

Did you upgrade to 1.1.x, run the migrate commanf and then upgrade to 1.2.x and run the migrate command again?

Sabit
27 Mar, 2023, 17:32

No I didn't do that

Sabit
27 Mar, 2023, 17:33

I immediately updated the version from 1.03 to 1.2. And then did the migration

Drake
27 Mar, 2023, 17:46

that's probably why you got the error then

Sabit
27 Mar, 2023, 19:06

And how to update the phone number without a password after logging in via OAuth2? Or is a password required?

Drake
27 Mar, 2023, 19:31

https://appwrite.io/docs/client/account?sdk=web-default#accountUpdatePassword. If you still need help, feel free to create a new <#1072905050399191082> post

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