generic-oauth2
generic-oauth2 copied to clipboard
Bug: Logout is not working and doesn't even return a boolean (it returns undefined)
Capacitor version:
Run npx cap doctor:
@capacitor/cli: 6.1.0
@capacitor/core: 6.1.0
@capacitor/android: 6.1.0
@capacitor/ios: 6.1.0
Library version:
- 3.0.1
- 2.1.0
- 2.0.0
- other: (Please fill in the version you are using.)
OAuth Provider:
- Azure AD (B2C)
- Github
- Other: (Please fill in the provider you are using.)
Your Plugin Configuration
const config: CapacitorConfig = {
appId: 'life.evam.hydras.cs',
appName: 'Central Services',
webDir: 'dist'
};
Affected Platform(s):
- Android
- Version/API Level:
- Device Model:
- Content of your
AndroidManifest.xml
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="@string/custom_url_scheme" android:host="oauth"/>
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
<service
android:name=".MessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<queries>
<package android:name="com.google.android.apps.maps"/>
</queries>
Current Behavior
The logout function doesn't log out at all. When calling the function it doesn't even return true or false (as documented) but returns undefined.
Expected Behavior
The logout function should log me out and return a boolean.
Sample Code or Sample Application Repo
// from another file
export const getOAuth2Options = async (): Promise<OAuth2AuthenticateOptions> => {
const {
appId,
keycloakBaseUrl
} = await getKeycloakBaseUrlAndAppId();
return {
authorizationBaseUrl: `${keycloakBaseUrl}/realms/cs/protocol/openid-connect/auth`,
accessTokenEndpoint: `${keycloakBaseUrl}/realms/cs/protocol/openid-connect/token`,
resourceUrl: `${keycloakBaseUrl}/realms/cs/protocol/openid-connect/userinfo`,
appId: "web",
scope: "openid email profile roles",
logsEnabled: true,
web: {
appId: "web",
redirectUrl: window.location.origin,
responseType: "token",
accessTokenEndpoint: "",
},
android: {
appId: "web",
redirectUrl: `${appId}:/`,
responseType: "code",
},
ios: {
appId: "web",
redirectUrl: `${appId}:/`,
responseType: "code"
}
}
};
// code which fails
const token = centralServices.accessToken
if (token !== null) getOAuth2Options().then(optns => {
GenericOAuth2.logout(optns, token).then((value) => {
console.log(JSON.stringify({
valueType: typeof value,
token
}))
localStorage.clear()
}).catch(err => console.log(JSON.stringify({
err
})));
})
``
### Reproduction Steps
<!-- Please explain the steps required to duplicate the issue, especially if you are able to provide a sample application. -->
### Other Information
<!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->