Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateToken() method does not refresh the access token #10

Open
ptawde95 opened this issue May 13, 2021 · 3 comments
Open

updateToken() method does not refresh the access token #10

ptawde95 opened this issue May 13, 2021 · 3 comments

Comments

@ptawde95
Copy link

Describe the bug :

Using the package i am trying to refresh the access token by calling updateToken method which makes the refreshtoken api request from keyclaok.js. but the request returns Status 400 Bad Request ,then i checked the request in browser tool(network tab),the refresh_token is passed as undefined. I also tried to passed -1 as parameter to the updateToken() which forcefully refresh the token.

access_token expires in : 1 min

Expected behavior :
The updatetoken method should refreshtoken if access token is expiry.

Flutter Version:
Flutter 2.0.1 • channel beta • https://github.com/flutter/flutter.git
Framework • revision c5a4b4029c (10 weeks ago) • 2021-03-04 09:47:48 -0800
Engine • revision 40441def69
Tools • Dart 2.12.0

@gibahjoe
Copy link
Owner

Hello, I just tested this on the sample app and it refreshes just fine. Please provide minimal code so that I can reproduce the error. Thanks

@ptawde95
Copy link
Author

ptawde95 commented May 17, 2021

Hi @gibahjoe Thanks for your Response.

Code to reproduce :

            // set the KeycloakConfig

          keycloakService = KeycloakService(KeycloakConfig(
                  url: '$keycloakIssuer://$keycloakWebDomain',
                  realm: '$keycloakRealm',
                  clientId: '$keycloakClientId',
                )); 
        
         // To listen all keycloak Events	
            
         keycloakService.keycloakEventsStream.listen((event) {
                  if (event.type == KeycloakEventType.onAuthSuccess) {
                    
        print('event.type == KeycloakEventType.onAuthSuccess IN MuApp OnInIt');
        print(event.type == KeycloakEventType.onAuthSuccess);

      

        ///ACCESS_TOKEN ACCESS
        keycloakService.getToken(true).then((value) {
          print('keycloakService.getToken Response');
          print(value);

        }).catchError((e) {
          print('keycloakService.getToken Error Response');
          print(e);
        });
      }

      if (event.type == KeycloakEventType.onAuthRefreshError) {
        print(event.type);
      }

      if (event.type == KeycloakEventType.onAuthLogout) {
        print(event.type);
      }

      if (event.type == KeycloakEventType.onAuthRefreshSuccess) {
        print(event.type);
      }
    });
	
                    // Keycloak Service initialization		

                    keycloakService.init(
                              initOptions: KeycloakInitOptions(
                              onLoad: 'check-sso',
                              enableLogging: true,
                              silentCheckSsoRedirectUri:'http://localhost/silent-check-sso.html',
                            
                            ));

Also Observed

  • Immediately after successfully login OnAuthLogout event is fired
  • the token expired event is not fired even after the token is expired

Console Logs :

image (10)

This occurs initially , but if i comment the updateToken method call in the getToken method of Keycloak service. i was able to get the access token.

@ptawde95
Copy link
Author

@gibahjoe Any update..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants