ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
51 stars 50 forks source link

[Bug]: Invalid argument (callbackUrlScheme) on macOS #91

Closed Sabin-DC closed 8 months ago

Sabin-DC commented 8 months ago

Description

I apologize if this isn't the place, i'm not sure how to open an issue as a question rather than a bug or where I could go to ask this. I'm sure it's a config issue, but basically the same code in windows works, but on macos throws this error

ArgumentError (Invalid argument (callbackUrlScheme): must be a valid URL scheme: "http://localhost:60665")

Minimal Reproduction

Steps to reproduce the behaviour:

  1. Use the following code:
    getCode() async {
      const clientID = 'PLACEHOLDER';
      const response_type = 'code';
      const redirect_uri = 'http://localhost:60665';
      const scope = 'write:users';
      final pkcePair = PkcePair.generate();
      final result = await FlutterWebAuth2.authenticate(
          url:
              'https://myanimelist.net/v1/oauth2/authorize?client_id=$clientID&redirect_uri=$redirect_uri&response_type=$response_type&scope=$scope&code_challenge=${pkcePair.codeChallenge}',
          callbackUrlScheme: 'http://localhost:60665');
      String code = Uri.parse(result).queryParameters['code']!;
      print(code);
    }
  2. [...]

Exception or Error

ArgumentError (Invalid argument (callbackUrlScheme): must be a valid URL scheme: "http://localhost:60665")

Expected Behaviour

Should open the browser

Screenshots

No response

Additional context

No response

Device

MacMini

OS

MacOS

Browser

Chrome

Flutter version

3.13.0

flutter_web_auth_2 version

3.1.1

Checklist

ThexXTURBOXx commented 8 months ago

This should be answered within the readme of this package or in the example. Basically, the current implementation for Windows and Linux needs a specific callback scheme. However, all the other platforms use "normal" ones as described there.

Sabin-DC commented 8 months ago

This should be answered within the readme of this package or in the example. Basically, the current implementation for Windows and Linux needs a specific callback scheme. However, all the other platforms use "normal" ones as described there.

I see, I guess I thought the windows way was the typical scheme, haven't been developing on mac for long. Sorry for the trouble, i'll close this and re-read the doc more thoroughly. Thank you!

ThexXTURBOXx commented 8 months ago

You're welcome! :)