capacitor-community / generic-oauth2

Generic Capacitor OAuth 2 client plugin. Stop the war in Ukraine!
MIT License
223 stars 106 forks source link

Question: What kind of browser is used for login? #246

Closed weihsth closed 6 months ago

weihsth commented 6 months ago

Hi,

first of all, thank you @moberwasserlechner for your efford!

I don't think it's a plugin-bug, so my question is, how to "kill" the oauth Browser-session (keycloak) on Android Device. Which type of Browser does this blugin use for the login-function? It's internally calling a browser, but which one?

I tried using Capacitor Browser like for iOS, but automatically closing with Browser.close() is not supported by that plugin.

Then I tried Cordova InAppBrowser:

private async handleAndroidSignOut(url: string): Promise<void> {
    return new Promise(resolve => {
        const ref = this.inAppBrowser.create(url, '_system', 'hidden=yes');
        return ref.on('loadstop')
            .pipe(take(1))
            .subscribe(() => {
                ref.close();
                resolve();
            });
    });
}

It's doing all the logout stuff and redirecting correctly, but if I click on login again, it automatically does a login without showing a login-page.

Do I use the wrong target here? this.inAppBrowser.create(url, '_system', 'hidden=yes');

I tried '_self', '_blank' and '_system'. But it's not logging me out.

On iOS it works with this code:

private async handleIosSignOut(url: string): Promise<void> {
    await Browser.open({url});
    await new Promise(resolve => {
        Browser.addListener('browserPageLoaded', () => resolve(true));
    });
    await Browser.close();
}

Does someone of this great community has any idea?

Regards!

weihsth commented 6 months ago

Seems that is works on native Phone, but not on Android Studio Simulator.