8000 Merge branch 'step-7-dev' into step-8-dev · cethap/sdk-node-tutorial@e2f089b · GitHub
[go: up one dir, main page]

Skip to content

Commit e2f089b

Browse files
committed
Merge branch 'step-7-dev' into step-8-dev
2 parents fc97695 + d8914f3 commit e2f089b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ Just replace this comment with a POST endpoint :
197197
app.post('/oauth/signin', function (req, res) {
198198
var code = req.body.code;
199199
// This sends the request to OAuth.io to get an access token
200-
oauth.auth(code, req)
200+
oauth.auth('google', req.session, {
201+
code: code
202+
})
201203
.then(function (r) {
202204
// Do something with r.access_token,
203205
// or r.get|post|put|delete|patch|me()
@@ -232,16 +234,19 @@ Just replace this comment with the following code :
232234

233235
```javascript
234236
app.get('/me', function (req, res) {
235-
// This creates a request object that allows you
236-
// to use the .get|post|put|delete|patch|me() methods
237-
var request_object = oauth.create(req);
238-
239-
// Here we'll use the me() method, but note that you
240-
// can get the same result from a .get('/me') to Facebook
241-
// and mapping its results to the right fields (name, email and avatar)
242-
request_object.me()
237+
// Here we first build a request object from the session with the auth method.
238+
// Then we perform a request using the .me() method.
239+
// This retrieves a unified object representing the authenticated user.
240+
// You could also use .get('/plus/v1/people/me') and map the
241+
// results to fields usable from the front-end
242+
// (which waits for the fields 'name', 'email' and 'avatar').
243+
oauth.auth('google', req.session)
244+
.then(function (request_object) {
245+
return request_object.me();
246+
})
243247
.then(function (r) {
244-
// r contains the response from OAuth.io's mapping of the /me endpoint // on facebook
248+
// r contains the response from OAuth.io's mapping of the
249+
// /plus/v1/people/me endpoint on google
245250
res.json(r);
246251
})
247252
.fail(function (e) {
@@ -376,7 +381,7 @@ with :
376381
function authenticate(token, callback) {
377382
// Launches a popup showing the provider's website
378383
// for the user to login and to accept permissions
379-
OAuth.popup('facebook', {
384+
OAuth.popup('google', {
380385
state: token
381386
})
382387
.done(function(r) {

0 commit comments

Comments
 (0)
0