gibahjoe / keycloak_flutter

Keycloak package for easy integration with flutter applications
BSD 3-Clause "New" or "Revised" License
24 stars 24 forks source link

Using example project event.type always has value of KeycloakEventType.onReady #26

Closed Marcell-Roos closed 1 year ago

Marcell-Roos commented 1 year ago

Description of the bug

When using the login buttons, I get redirected to the Keycloak login page. After a successful login, the event.type stil has a value of KeycloakEventType.onReady. After I perform a logout, the value of event.type is still KeycloakEventType.onReady.

Steps to reproduce

Open the example application in android studio and attempt to login with valid credentials

Expected behavior

When a login is done, the event.type to have a valye of onAuthSuccess and when a logout is done, for the event.type to have a value of onAuthLogout

Logs

Performing hot restart...
Waiting for connection from debug service on Chrome...
Restarted application in 267ms.
KeycloakEventType.onReady
KeycloakEventType.onReady
KeycloakEventType.onReady
KeycloakEventType.onReady
KeycloakEventType.onReady
KeycloakEventType.onReady

Screenshots

No response

Platform

Windows

Browser

Chrome

Keycloak web version

21.1.2

Keycloak flutter version

0.0.21

Flutter version

3.3

Flutter channel

stable

Additional context

I am new to using flutter and Keycloak is it is possible that I have missed something but I did follow your setup and get as far as being directed to my Keycloak client login page so I am not sure how to move forward here.
Marcell-Roos commented 1 year ago

I added an alert to silent-check-sso.html to get the value of location.href and recieved the below

http://localhost:52934/silent-check-sso.html?error=interaction_required&state=7f00fe6a-acdf-4c3a-9cd6-1ff625562486

So does error=interaction_required mean anything meaningful?

Marcell-Roos commented 1 year ago

I found the issue was that my user had an action it needed to perform on login. I fixed that but now I receive this error on successful login and redirect.


Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:62459/x1tCrafl0jI=/ws
Debug service listening on ws://127.0.0.1:62459/x1tCrafl0jI=/ws
Debug service listening on ws://127.0.0.1:62459/x1tCrafl0jI=/ws
KeycloakEventType.onReady
Error: NoSuchMethodError: ''
Dynamic call with too few arguments. Expected: 1 Actual: 0
Receiver: Instance of '(KeycloakError) => Null'
Arguments: []
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 288:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 813:3   defaultNoSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 64:17                 noSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 808:31  noSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 283:12  callNSM
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 369:10  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39  dcall
js/keycloak.js 1455:47                                                            onreadystatech
```ange
Marcell-Roos commented 1 year ago

All issues were related to my stupidity in configuring the client. Apologies.