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

Update persistent refresh token documentation with more accurate details #329

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Creates the authorization URL from the *client configuration* and the *authorize

Additional options will be automatically serialized as query params in the resulting URL.

#### .getToken(params, [httpOptions]) => Promise<AccessToken>
#### await .getToken(params, [httpOptions]) => AccessToken
Get a new access token using the current grant type.

* `params`
Expand All @@ -61,12 +61,12 @@ Additional options will be automatically serialized as params for the token requ
* `httpOptions` All [wreck](https://github.com/hapijs/wreck) options can be overriden as documented by the module `http` options.

#### .createToken(token) => AccessToken
Creates a new access token by providing a valid plain token object.
Creates a new access token by providing a token object as specified by [RFC6750](https://tools.ietf.org/html/rfc6750#section-4).

### new ResourceOwnerPassword(options)
This submodule provides support for the OAuth2 [Resource Owner Password Credentials](https://oauth.net/2/grant-types/password/) grant type.

#### .getToken(params, [httpOptions]) => Promise<AccessToken>
#### await .getToken(params, [httpOptions]) => AccessToken
Get a new access token using the current grant type.

* `params`
Expand All @@ -79,12 +79,12 @@ Additional options will be automatically serialized as params for the token requ
* `httpOptions` All [wreck](https://github.com/hapijs/wreck) options can be overriden as documented by the module `http` options.

#### .createToken(token) => AccessToken
Creates a new access token by providing a valid plain token object.
Creates a new access token by providing a token object as specified by [RFC6750](https://tools.ietf.org/html/rfc6750#section-4).

### new ClientCredentials(options)
This submodule provides support for the OAuth2 [Client Credentials](https://oauth.net/2/grant-types/client-credentials/) grant type.

#### .getToken(params, [httpOptions]) => Promise<AccessToken>
#### await .getToken(params, [httpOptions]) => AccessToken
Get a new access token using the current grant type.

* `params`
Expand All @@ -95,26 +95,26 @@ Additional options will be automatically serialized as params for the token requ
* `httpOptions` All [wreck](https://github.com/hapijs/wreck) options can be overriden as documented by the module `http` options.

#### .createToken(token) => AccessToken
Creates a new access token by providing a valid plain token object.
Creates a new access token by providing a token object as specified by [RFC6750](https://tools.ietf.org/html/rfc6750#section-4).

### AccessToken
#### .expired([expirationWindowSeconds]) => Boolean
Determines if the current access token is definitely expired or not

* `expirationWindowSeconds` Window of time before the actual expiration to refresh the token. Defaults to **0**.

#### .refresh(params) => Promise<AccessToken>
#### await .refresh(params) => AccessToken
Refreshes the current access token. The following params are allowed:

* `params`
* `[scope]` Optional string or array including a subset of the original token scopes to request

Additional options will be automatically serialized as query params for the token request.

#### .revoke(tokenType) => Promise
#### await .revoke(tokenType)
Revokes either the access or refresh token depending on the {tokenType} value. Token type can be one of: `access_token` or `refresh_token`.

#### .revokeAll() => Promise
#### await .revokeAll()
Revokes both the current access and refresh tokens

#### .token
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## Next
### Maintainance
- Documentation updates for persistent access token refresh

## 4.1.0
### Improvements
- [#398](https://github.com/lelylan/simple-oauth2/pull/328) Add support to refresh persitent access tokens
- [#398](https://github.com/lelylan/simple-oauth2/pull/328) Add support to refresh persistent access tokens

### Maintainance
- [#326](https://github.com/lelylan/simple-oauth2/pull/326) Remove usage of [date-fns](https://date-fns.org/) production dependency
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async function run() {
run();
```

Once we have determined the access token needs refreshing with the [.expired()](./API.md##expiredexpirationwindowseconds--boolean) method, we can finally refresh it with a [.refresh()](#refreshparams--promiseaccesstoken) method call.
Once we have determined the access token needs refreshing with the [.expired()](./API.md#expiredexpirationwindowseconds--boolean) method, we can finally refresh it with a [.refresh()](./API.md#await-refreshparams--accesstoken) method call.

```javascript
async function run() {
Expand Down