@@ -197,7 +197,9 @@ Just replace this comment with a POST endpoint :
197
197
app .post (' /oauth/signin' , function (req , res ) {
198
198
var code = req .body .code ;
199
199
// 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
+ })
201
203
.then (function (r ) {
202
204
// Do something with r.access_token,
203
205
// or r.get|post|put|delete|patch|me()
@@ -232,16 +234,19 @@ Just replace this comment with the following code :
232
234
233
235
``` javascript
234
236
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
+ })
243
247
.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
245
250
res .json (r);
246
251
})
247
252
.fail (function (e ) {
@@ -376,7 +381,7 @@ with :
376
381
function authenticate (token , callback ) {
377
382
// Launches a popup showing the provider's website
378
383
// for the user to login and to accept permissions
379
- OAuth .popup (' facebook ' , {
384
+ OAuth .popup (' google ' , {
380
385
state: token
381
386
})
382
387
.done (function (r ) {
0 commit comments