-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
27 lines (25 loc) · 1020 Bytes
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const passport = require('passport');
/*
* Simple informational end point, if you want to get information
* about a particular client. You would call this with an access token
* in the body of the message according to OAuth 2.0 standards
* http://tools.ietf.org/html/rfc6750#section-2.1
*
* Example would be using the endpoint of
* https://localhost:3000/api/userinfo
*
* With a GET using an Authorization Bearer token similar to
* GET /api/userinfo
* Host: https://localhost:3000
* Authorization: Bearer someAccessTokenHere
*/
exports.info = [
passport.authenticate('bearer', { session: false }), (req, res) => {
// req.authInfo is set using the `info` argument supplied by
// `BearerStrategy`. It is typically used to indicate scope of the token,
// and used in access control checks. For illustrative purposes, this
// example simply returns the scope in the response.
res.json({ client_id: req.user.id, name: req.user.name, scope: req.authInfo.scope });
},
];