Back

[SOLVED] Flutter web Oauth2 cannot return to the previous interface

  • 0
  • Flutter
joser
1 Sep, 2023, 07:54

Flutter web uses Appwrite Oauth2 authorization to set the success callback to automatically open the new Flutter web app and cannot return to the previous interface

TL;DR
Summary: The user had an error with Flutter web Oauth2 where they couldn't return to the previous interface. Another user suggested adding the web platform to solve the error reporting problem. The original user asked if they still needed to register the web platform even though they were using Flutter web. The solution was to add a web platform and the user shared code that demonstrates the implementation. However, they encountered a new error regarding the success URL. The error ID for this new error was provided. Another user asked if the error was occurring regularly and which endpoint it was happening on. The original user confirmed that it was happening regularly and shared another error
Drake
1 Sep, 2023, 15:25
joser
5 Sep, 2023, 01:27

Sorry, I misunderstood. I should design a successful callback address like host/auth.html instead of pointing to another path.

Drake
5 Sep, 2023, 01:46

Yes

joser
6 Sep, 2023, 00:39

I tested the authorization login of github locally. After it was successfully released, the authorization error was as follows

joser
6 Sep, 2023, 00:40

Error 500 Duplicated document: Duplicate entry 'ip:113.118.169.94-2023-09-06 00:00:00.000' for key '_32814_abuse.unique1' Error ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Drake
6 Sep, 2023, 01:25

This only happens if you're hitting some endpoint too fast 🧐. Is this happening regularly? What endpoint is this occurring on?

joser
6 Sep, 2023, 01:37

I didn't click either. It will be normal soon. Authorize and log in.

joser
6 Sep, 2023, 01:37

But the latest error report has changed

joser
6 Sep, 2023, 01:37

Invalid success: URL host must be one of: localhost, cloud.appwrite.io Error ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

joser
6 Sep, 2023, 01:38

final account = Account(client); var host = 'http://localhost:53137'; if (kReleaseMode) { host = 'https://winnerapp.github.io'; }

TypeScript
try {
  await account.createOAuth2Session(
    provider: 'github',
    success: '$host/auth.html',
  );
  final user = await account.get();
  final userPrefs = await account.getPrefs();
  global.userR.value = user;
  Get.back();
}
joser
6 Sep, 2023, 01:39
TypeScript
 final account = Account(client);
    var host = 'http://localhost:53137';
    if (kReleaseMode) {
      host = 'https://winnerapp.github.io';
    }

    try {
      await account.createOAuth2Session(
        provider: 'github',
        success: '$host/auth.html',
      );
      final user = await account.get();
      final userPrefs = await account.getPrefs();
      global.userR.value = user;
      Get.back();
    }
Drake
6 Sep, 2023, 01:45
joser
6 Sep, 2023, 01:49

But I wrote it based on Flutter Web, not a real web platform

Drake
6 Sep, 2023, 01:50
joser
6 Sep, 2023, 01:52

You mean, although I use flutter web, I still need to register the web platform to use it, right? Not the flutter platform.

Drake
6 Sep, 2023, 01:53

Sure, yes

joser
6 Sep, 2023, 01:54

Ok, I'll give it a try.

joser
6 Sep, 2023, 01:57

Thank you, I added the web platform to solve my error reporting problem.

safwan
6 Sep, 2023, 04:19

Hey @joser is tyour problem solved?

joser
7 Sep, 2023, 00:50

YES

Drake
7 Sep, 2023, 00:50

[SOLVED] Flutter web Oauth2 cannot return to the previous interface

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