simple-oauth2
Advanced tools
Comparing version 2.0.0 to 2.0.1
# Changelog | ||
## v2.0.1 | ||
* Add support to revoke accessToken and refreshToken in a single call with `revokeAll` | ||
## v2.0.0 | ||
@@ -4,0 +8,0 @@ |
@@ -67,2 +67,10 @@ 'use strict'; | ||
} | ||
/** | ||
* Revoke both the existing access and refresh tokens | ||
*/ | ||
async revokeAll() { | ||
await this.revoke('access_token'); | ||
await this.revoke('refresh_token'); | ||
} | ||
} | ||
@@ -69,0 +77,0 @@ |
{ | ||
"name": "simple-oauth2", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Node.js client for OAuth2", | ||
@@ -53,3 +53,3 @@ "author": "Andrea Reginato <andrea.reginato@gmail.com>", | ||
"lodash": "^4.17.5", | ||
"mocha": "^4.0.1", | ||
"mocha": "^5.0.1", | ||
"nock": "^9.0.13", | ||
@@ -56,0 +56,0 @@ "nyc": "^11.4.1" |
@@ -136,3 +136,4 @@ # Simple OAuth2 | ||
code: '<code>', | ||
redirect_uri: 'http://localhost:3000/callback' | ||
redirect_uri: 'http://localhost:3000/callback', | ||
scope: '<scope>', // also can be an array of multiple scopes, ex. ['<scope1>, '<scope2>', '...'] | ||
}; | ||
@@ -163,3 +164,4 @@ | ||
username: 'username', | ||
password: 'password' | ||
password: 'password', | ||
scope: '<scope>', // also can be an array of multiple scopes, ex. ['<scope1>, '<scope2>', '...'] | ||
}; | ||
@@ -182,3 +184,5 @@ | ||
const oauth2 = require('simple-oauth2').create(credentials); | ||
const tokenConfig = {}; | ||
const tokenConfig = { | ||
scope: '<scope>', // also can be an array of multiple scopes, ex. ['<scope1>, '<scope2>', '...'] | ||
}; | ||
@@ -255,7 +259,6 @@ // Get the access token object for the client | ||
```javascript | ||
// Revoke both access and refresh tokens | ||
try { | ||
// Revoke only the access token | ||
await accessToken.revoke('access_token') | ||
await accessToken.revoke('access_token'); | ||
@@ -270,2 +273,14 @@ // Session ended. But the refresh_token is still valid. | ||
As a convenience method, you can also revoke both tokens in a single call: | ||
```javascript | ||
// Revoke both access and refresh tokens | ||
try { | ||
// Revokes both tokens, refresh token is only revoked if the access_token is properly revoked | ||
await accessToken.revokeAll(); | ||
} catch (error) { | ||
console.log('Error revoking token: ', error.message); | ||
} | ||
``` | ||
### Errors | ||
@@ -272,0 +287,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137322
31
705
325