Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logout() docs #278

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ import { GenericOAuth2 } from '@capacitor-community/generic-oauth2';
@Component({
template:
'<button (click)="onOAuthBtnClick()">Login with OAuth</button>' +
'<button (click)="onOAuthRefreshBtnClick()">Refresh token</button>' +
'<button (click)="onLogoutClick()">Logout OAuth</button>',
'<button (click)="onOAuthRefreshBtnClick()">Refresh token</button>',
})
export class SignupComponent {
accessToken: string;
Expand All @@ -107,7 +106,7 @@ export class SignupComponent {
onOAuthBtnClick() {
GenericOAuth2.authenticate(oauth2Options)
.then(response => {
this.accessToken = response['access_token']; // storage recommended for android logout
this.accessToken = response['access_token'];
this.refreshToken = response['refresh_token'];

// only if you include a resourceUrl protected user values are included in the response!
Expand All @@ -129,7 +128,7 @@ export class SignupComponent {

GenericOAuth2.refreshToken(oauth2RefreshOptions)
.then(response => {
this.accessToken = response['access_token']; // storage recommended for android logout
this.accessToken = response['access_token'];
// Don't forget to store the new refresh token as well!
this.refreshToken = response['refresh_token'];
// Go to backend
Expand All @@ -138,19 +137,6 @@ export class SignupComponent {
console.error('Refreshing token failed', reason);
});
}

onLogoutClick() {
GenericOAuth2.logout(
oauth2LogoutOptions,
this.accessToken, // only used on android
)
.then(() => {
// do something
})
.catch(reason => {
console.error('OAuth logout failed', reason);
});
}
}
```

Expand Down Expand Up @@ -187,7 +173,7 @@ Example:
}
```

#### authenticate() and logout()
#### authenticate()

**Overrideable Base Parameter**

Expand Down Expand Up @@ -232,6 +218,10 @@ These parameters are overrideable in every platform
| customHandlerClass | | | Provide a class name implementing `CapacitorCommunityGenericOauth2.OAuth2CustomHandler` | |
| siwaUseScope | | | SiWA default scope is `name email` if you want to use the configured one set this param `true` | 2.1.0 |

#### logout()

The existing `logout()` method has some issues and is not currently functional. See [Issue #97](https://github.com/capacitor-community/generic-oauth2/issues/97) for possible workarounds.

#### refreshToken()

| parameter | default | required | description | since |
Expand Down