0

Having an issue logging out of a device-application instance using

https://github.com/passport/express-4.x-facebook-example

What I am trying to do is issue a DELETE request to

https://graph.facebook.com/me/permissions?access_token

but am having a problem with the correct syntax.

Am trying the following using the request module after defining a /logout route. But not working

Any Passport, Express experts that can help?

var express = require('express');
var request = require('request');
var app = express();
app.get('/logout',
  function(req, res){
    res.render('login');
    request.delete("https://graph.facebook.com/me/permissions?access_token=" + ACCESS_TOKEN);

  });
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Bachalo
  • 6,965
  • 27
  • 95
  • 189

1 Answers1

0

That's not how you make a delete request from an express application. The app object doesn't make http calls to other servers. Your confusing declaring a route that handles a delete call with making one.

You need to use a library that let's you make http calls. I like:

https://github.com/request/request

But there are many ways to go.

It's pretty extreme to be deleting the users access token just because they've logged out. I've never seen that done before.

Robert Moskal
  • 21,737
  • 8
  • 62
  • 86
  • Thanks. Please see my revised question. Still having a problem with correct combination of request and express routing. Any feedback appreciated! – Bachalo Jun 08 '16 at 15:12
  • What's the problem? – Robert Moskal Jun 08 '16 at 15:18
  • Is my code sample 'correct'? Not sure if I can make a request call like this within a routing callback. – Bachalo Jun 08 '16 at 15:20
  • more or less. I don't think you should be doing the render before you make the call. .You should return the results in the callback from the request. Why don't you try it and see? It's much more effective than having people look at code on the internet. – Robert Moskal Jun 08 '16 at 15:24
  • of course I have been trying, my goal is to force a device logout from a user account via the api. I was making a call to facebook.com/logout.php?next=http://localhost:9999/logout but this stopped working for some reason. The /logout route is never reached. So am desperately looking for alternatives. :( – Bachalo Jun 08 '16 at 16:03
  • this was my inspiration for trying a http delete http://stackoverflow.com/questions/12873960/passport-js-facebook-strategy-logout-issue – Bachalo Jun 08 '16 at 16:11