casdoor / casdoor-flutter-sdk

Flutter SDK for Casdoor, see example at: https://github.com/casdoor/casdoor-flutter-example
https://github.com/casdoor/casdoor
Apache License 2.0
12 stars 13 forks source link

Fix error in code #19

Closed pyxiscloud closed 1 year ago

pyxiscloud commented 1 year ago

3 days trying to get auth working in flutter web. It works after commenting this at castor.dart

Uri getSigninUrl({String scope = "read", String? state}) {

    return Uri.https(config.endpoint, "login/oauth/authorize", {

      "client_id": config.clientId,

      "response_type": "code",

      "scope": scope,

      "state": state ?? config.appName,

      // "code_challenge_method": "S256",

      // "nonce": nonce,

      // "code_challenge": generateCodeChallenge(codeVerifier),

      "redirect_uri": config.redirectUri

    });

  }

please fix sources?

ps: still not works for flutter build web --release (

casbin-bot commented 1 year ago

@seriouszyx @ComradeProgrammer @Resulte

muchengl commented 1 year ago

Hello, I tried to fix this problem. Do you mean that in your project, the SDK code needs to be modified as follows to work normally? 图片 1

However, in my demo, the sdk can't work if doing this modification. So I can't repeat the problem.

I wonder, maybe I misunderstand your issue or your issue can only happen in some special situations. Could you give me some more details? Thanks!

caoshengdong commented 1 year ago

@pyxiscloud Can you provide a demo project?

pyxiscloud commented 1 year ago

Hello @muchengl Yes, I mean that (without changing SDK code not running normally) I think it depends on Casdoor server settings, but not sure. My casdoor server only with captcha provider. My steps:

  1. Deploy clean casdoor (docker) + add 1 application with Sign Up only with captcha provider.
  2. Trying to test it with demo example.
muchengl commented 1 year ago

@pyxiscloud Hello, I have set up a demo according to your steps and encountered a "cross-domain problem". Is this your problem? Or you may have encountered another error.

截屏2022-11-23 19 52 20
hsluoyz commented 1 year ago

@pyxiscloud can you run the Flutter example code? https://github.com/casdoor/casdoor-flutter-example

pyxiscloud commented 1 year ago

no, that example not works testing on Chrome, development mode (flutter web)

  1. I've pressed FAB button
  2. New window opens with Casdoor Login Window
  3. I 've entered as admin (admin - 123)
  4. Window was closed, but token is still "User is not logged in" image
hsluoyz commented 1 year ago

@pyxiscloud did you see this? https://github.com/casdoor/casdoor-flutter-sdk#web:~:text=On%20the%20Web%20platform%20an%20endpoint%20needs%20to%20be%20created%20that%20captures%20the%20callback%20URL%20and%20sends%20it%20to%20the%20application%20using%20the%20JavaScript%20postMessage()%20method.

How did you setup that callback endpoint? Can you provide the code?

hsluoyz commented 1 year ago

The example code: https://github.com/casdoor/casdoor-flutter-example works. So don't know why the issue owner doesn't work.

Closed as stale.