capacitor-community / capacitor-community/generic-oauth2
Bug: Logout is not working and doesn't even return a boolean (it returns undefined)
- Dominant language
- Java
- Stars
- 281
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
### 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:
- Google
- Facebook
- Azure AD (B2C)
- Github
- Other: (Please fill in the provider you are using.)
### Your Plugin Configuration
```typescript
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`
```xml
```
* iOS
* Version/API Level:
* Device Model:
* Content of your `Info.plist`
```xml
```
* Web
* Browser:
### 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
```typescript
// from another file
export const getOAuth2Options = async (): Promise => {
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
### Other Information
Contributor guide
Research direction
Start at the supplied GenericOAuth2.logout(optns, token) call and compare the documented boolean contract with the plugin's logout behavior for the reported Capacitor Android setup. Reproduce the call with the provided OAuth options and token; done means logout invalidates the session and resolves to an explicit boolean rather than undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, typescript
- Domain
- authentication, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100