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
@@ -114,12 +123,56 @@ If all goes as planned, you should receive a response like this:
114
123
}
115
124
```
116
125
126
+
#### With *refresh_token* grant
127
+
128
+
When obtaining an access token using *password* grant, you get also a refresh token.
129
+
With this token you can get a new access token, using only that value (username and password are not needed), while it has not been expired.
130
+
131
+
> Remember that, if you refresh a token while it was still valid, the old access and refresh tokens get revoked, and only the new access and refresh tokens are valid to be used.
132
+
133
+
You need to include the client credentials in request headers and the refresh token and grant type in request body:
Now, you can use your brand-new token to access restricted areas. For example, you can GET to `http://localhost:3000/` including your token at headers:
120
173
121
174
***Headers**
122
-
* **Authorization**: `"Bearer " + access_token`
175
+
* **Authorization**: `"Bearer " + accessToken`
123
176
* (for example, `Bearer 951d6f603c2ce322c5def00ce58952ed2d096a72`)
Copy file name to clipboardExpand all lines: model.js
+42-2Lines changed: 42 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,12 @@
4
4
5
5
varconfig={
6
6
clients: [{
7
+
id: 'application',// TODO: Needed by refresh_token grant, because there is a bug at line 103 in https://github.com/oauthjs/node-oauth2-server/blob/v3.0.1/lib/grant-types/refresh-token-grant-type.js (used client.id instead of client.clientId)
7
8
clientId: 'application',
8
9
clientSecret: 'secret',
9
10
grants: [
10
-
'password'
11
+
'password',
12
+
'refresh_token'
11
13
],
12
14
redirectUris: []
13
15
}],
@@ -111,6 +113,42 @@ var getUserFromClient = function(client) {
0 commit comments