Back

[SOLVED] Flutter Web OAuth

  • 0
  • Flutter
  • Web
  • Android
  • Accounts
  • Apple
zwarag\\harrys
7 Apr, 2023, 21:32

I am using the Gitlab OAuth2 Provider to do the authentication and it worked perfectly in iOS and Android. However, when I run the application in Web mode. I get stuck on the callback page (see first screenshot).

According to https://appwrite.io/docs/getting-started-for-flutter#web I added the web/auth.html And adapted my call

TypeScript
await _account.createOAuth2Session(
        provider: 'gitlab',
        success: 'http://localhost:8000/auth.html',
        failure: 'http://localhost:8000/',
      );

Now the web works, but the iOS and Android get stuck (see second screenshot).

What am I doing wrong 🙂

TL;DR
The user is having trouble with Flutter Web OAuth. They are using the Gitlab OAuth2 Provider and it works on iOS and Android but gets stuck on the web. They asked for help on how to check if the platform is web or iOS. Another user suggests using the `kIsWeb` constant to conditionally pass the `auth.html` page. The user also shares a code snippet to run Flutter with a specific port. The issue is solved with the provided solution.
Drake
7 Apr, 2023, 21:33

you'll need to have a condition to pass the auth.html only if the platform is web. you can use the kIsWeb constant.

zwarag\\harrys
7 Apr, 2023, 21:39

well that was the fastest help i ever got, thx a lot @Steven ❤️

Drake
7 Apr, 2023, 21:40

happy to help! <:appwritepeepo:902865250427215882>

Tessa
7 Apr, 2023, 21:41

[SOLVED] Flutter Web OAuth

Hoàng Quốc An
25 May, 2023, 18:11

Hi @zwaragharrys can i have a question. Did you run flutter with specific port 8000?

zwarag\\harrys
25 May, 2023, 18:20

yes, I'm using vscode you can create a file .vscode/launch.json with the following code. This allows you to run the application with a fixed port.

TypeScript
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutterome",
            "request": "launch",
            "type": "dart",
            "args": [
                "-d",
                "chrome",
                "--web-port",
                "8000"
            ],
        }
    ]
}
Hoàng Quốc An
25 May, 2023, 18:22

Ok. Thanks for your answer!

Hoàng Quốc An
25 May, 2023, 18:31

Ak. If you have resolved with how to check if platform is web or and or ios, can you share me your code? Tks a lot!

zwarag\\harrys
25 May, 2023, 19:41

It would be something like this:

TypeScript
await _account.createOAuth2Session(
        provider: 'gitlab',
        success: kIsWeb ? null : 'http://localhost:8000/auth.html'
      );
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