Skip to content

Commit

Permalink
Merge pull request #329 from lelylan/feature/persistent-refresh-token…
Browse files Browse the repository at this point in the history
…s-doc-fix

Update persistent refresh token documentation with more accurate details
  • Loading branch information
jonathansamines authored Jun 12, 2020
2 parents 29e4001 + b8af3f8 commit 1771053
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
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

0 comments on commit 1771053

Please sign in to comment.