You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Determines if the current access token is definitely expired or not
@@ -107,3 +116,8 @@ Revokes either the access or refresh token depending on the {tokenType} value. T
107
116
108
117
#### .revokeAll() => Promise
109
118
Revokes both the current access and refresh tokens
119
+
120
+
#### .token
121
+
Immutable object containing the token object provided while constructing a new access token instance. This property will usually have the schema as specified by [RFC6750](https://tools.ietf.org/html/rfc6750#section-4), but the exact properties may vary between authorization servers.
122
+
123
+
Please also note, that the current implementation will always add an **expires_at** property regardless of the authorization server response, as we require it to to provide the refresh token functionality.
Copy file name to clipboardExpand all lines: README.md
+27-2Lines changed: 27 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,7 +159,32 @@ On completion of any [supported grant type](#supported-grant-types) an access to
159
159
160
160
#### Refresh an access token
161
161
162
-
When a token expires we need a mechanism to obtain a new access token. The [AccessToken](./API.md#accesstoken) methods can be used to perform the token refresh process.
162
+
On long lived applications, it is often necessary to refresh access tokens. In such scenarios the access token is usually persisted in an external database by first serializing it.
By the time we need to refresh the persistent access token, we can get back an [AccessToken](./API.md#accesstoken) instance by using the client's [.createToken](./API.md#createtokentoken--accesstoken) method.
let accessToken =client.createToken(JSON.parse(accessTokenJSONString));
182
+
}
183
+
184
+
run();
185
+
```
186
+
187
+
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.
163
188
164
189
```javascript
165
190
asyncfunctionrun() {
@@ -179,7 +204,7 @@ async function run() {
179
204
run();
180
205
```
181
206
182
-
The `expired` helper is useful for knowing when a token has definitively expired. However, there is a common race condition when tokens are near expiring. If an OAuth 2.0 token is issued with a `expires_in` property (as opposed to an `expires_at` property), there can be discrepancies between the time the OAuth 2.0 server issues the access token and when it is received.
207
+
The [.expired()](./API.md##expiredexpirationwindowseconds--boolean) helper is useful for knowing when a token has definitively expired. However, there is a common race condition when tokens are near expiring. If an OAuth 2.0 token is issued with a `expires_in` property (as opposed to an `expires_at` property), there can be discrepancies between the time the OAuth 2.0 server issues the access token and when it is received.
183
208
184
209
These come down to factors such as network and processing latency and can be worked around by preemptively refreshing the access token:
0 commit comments