appsup-dart / openid_client

Library for working with OpenID Connect and implementing clients.
BSD 3-Clause "New" or "Revised" License
90 stars 118 forks source link

Flutter web authentication issue with Keycloak #17

Closed Tijs-2 closed 4 years ago

Tijs-2 commented 4 years ago

Maybe I am doing something incorrectly but I try to use the browser authentication inside a flutter web application.

I get authenticated by, at least I think I am, because I get an id token. but do not get a expires_at/expires_in or refresh token. What I understand from different sites is that you should not get a refresh token so that is ok?

Now when I try to get the user data like the code below I get an error: "Invalid argument: null". I think that is because I haven't set the accessToken but I did not receive it.

My code:

import 'package:openid_client/openid_client_browser.dart' as openIdBrowser;
static const List<String> _scopes = ['openid', 'profile', 'email', 'roles'];
....

var authenticator = new openIdBrowser.Authenticator(this._client, scopes: _scopes);
 _credential = await authenticator.credential;

if (_credential==null) {
      // starts the authentication
      authenticator.authorize(); // this will redirect the browser
}
print("Userinfo: ${await _credential.getUserInfo()}");

Is an id token what is needed or am I doing something wrong?

I am also using the library for the app version and that seems to work fine.

Tijs

rbellens commented 4 years ago

This was indeed a bug that happened on for example keycloak. It should be fixed in next version 0.3.0