I'm trying to build a Foursquare app and I've selected the Everyauth module to implement the authentication (Connect with Foursquare).
I'm getting the error
Error: Step getAccessToken of `foursquare` module timed out.
after the user allows the app. Here is the code I'm using:
var express = require('express'),
util = require('util'),
helper = require('./helper'),
settings = require('./settings').appSettings,
everyauth = require('everyauth');
everyauth.foursquare
.entryPath('/auth/foursquare')
.callbackPath('/auth/foursquare/callback');
//everyauth.everymodule.moduleTimeout(-1);
everyauth.foursquare
.appId(settings.appId)
.appSecret(settings.appSecret)
.findOrCreateUser( function (session, accessToken, accessTokenExtra, foursquareUserMetadata) {
util.inspect(arguments);
return {};
})
.redirectPath('/');
var app = express.createServer(
express.bodyParser()
, express.static(__dirname + "/public")
, express.favicon()
, express.cookieParser()
, express.session({ secret: '*****'})
, everyauth.middleware()
);
app.get('/', function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<html><head></head><body><a href="' + helper.getAuthUrl() + '">Connect with Foursquare</a></body></html>');
});
everyauth.helpExpress(app);
app.listen(4040);
My mistake, I was redirecting the users to the app authentication url as described in the Foursquare documentation. It works if I redirect the user to /auth/foursquare/, as everyauth handles the redirect to oauth provider.