teranetsrl / oauth2_client

Simple Dart library for interacting with OAuth2 servers.
BSD 2-Clause "Simplified" License
91 stars 113 forks source link

fullscreen LoginView on Tablet #112

Open Abaddon-88 opened 2 years ago

Abaddon-88 commented 2 years ago

Hey,

I built the plugin into my Flutter project and everything works so far. I have the following problem on the Ipad.

After I have confirmed the alert, the LoginView opens. However, this does not take up the whole page but is similar to a popup

How do I get the login window to its full width / height on a tablet.

I could not find any information on adjusting the login view in the documentation

I use the OAuth2Client and the OAuth2Helper classes

gregertw commented 2 years ago

getTokenWithAuthCodeFlow() (and the other flows) takes a BaseWebAuth optional parameter, so you can override the web auth class. If you look in browser_web_auth.dart, you see that the login window is defined like this:

final popupLogin = html.window.open(
        url,
        'oauth2_client::authenticateWindow',
        'menubar=no, status=no, scrollbars=no, menubar=no, width=1000, height=500');

You can implement your own BaseWebAith overriding authenticate() to your own logic.

okrad commented 2 years ago

Thank you @gregertw for the suggestion, it would definitely be a viable solution. Anyway I was thinking that we could exploit the "opts" parameter of the authenticate method to pass custom arguments to the popup window, such as the desired width and height.

Do you think it would an useful addition?

gregertw commented 2 years ago

@okrad apologies, this one slipped. Yes, that would absolutely be a better approach. A similar challenge (need for opts but on scopes on refreshToken) is when you try to support AAD as it requires more granularity in the scopes when you first do OIDC and then need to request an access token to a specific resource. You can see how I did it https://github.com/gregertw/cognite_flutter_demo/blob/master/lib/providers/aad.dart