oauth2orize-validate-token
vundefined
Published
OAuth2orize middleware to validate bearer token
Readme
oauth2orize-validate-bearer
Bearer token validation exchange middleware for OAuth2orize.
Install
$ npm install oauth2orize-validate-bearer
Usage
Register Exchange Middleware
This exchange middleware is used by clients to validate an access token.
server.exchange('urn:ietf:params:oauth:grant-type:validate_bearer', validate_bearer(function (client, access_token, done) {
AccessToken.find(access_token, function (err, token) {
if (err) {
return done(err);
}
if (!token) {
return done();
}
var params = {
client_id : token.client_id,
expires_in : token.expires_in
};
if (token.user_id) {
params.user_id = token.user_id;
}
return done(null, token.access_token, token.refresh_token, params);
});
}));
The following is a sample request using curl against a fictitious server
curl -ik https://localhost:1337/oauth2/token -XPOST -d "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Avalidate_bearer&client_id=client_id&token=53166d5a-e407-416c-8248-212f271b3c8a"