Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

express 2 not working #36

Closed
c0d3x42 opened this issue Mar 20, 2011 · 13 comments
Closed

express 2 not working #36

c0d3x42 opened this issue Mar 20, 2011 · 13 comments

Comments

@c0d3x42
Copy link

c0d3x42 commented Mar 20, 2011

using the example twitter app, and express 2.0.0 and connect-auth 0.2.2

var twitterConsumerKey= 'MYKEY';
var twitterConsumerSecret= 'MYSECRET';
var express= require('express');
var connect= require('connect');
var auth= require('connect-auth');
var app = express.createServer();
app.configure(function(){
app.use(connect.cookieParser());
app.use(connect.session({ secret: 'foobar' }));
app.use(auth( [
 auth.Twitter({consumerKey: twitterConsumerKey, consumerSecret:    twitterConsumerSecret})]) );
});
app.get('/', function(req, res){
    req.authenticate(['twitter'], function(error, authenticated) {
        res.send('Hello World: ' + JSON.stringify( req.session.auth.user ) );
    });
});
app.listen(8080);

I'm getting the following from node 0.4.2:

http.js:521
    throw new Error("Can't use mutable header APIs after sent.");
          ^
Error: Can't use mutable header APIs after sent.
    at ServerResponse.getHeader (http.js:521:11)
    at ServerResponse.header  /home/vince/.node_libraries/.npm/express/2.0.0/package/lib/response.js:226:17)
    at ServerResponse.send  (/home/vince/.node_libraries/.npm/express/2.0.0/package/lib/response.js:65:17)
    at /tmp/app2.js:16:9
    at /home/vince/.node_libraries/.npm/connect-auth/0.2.2/package/lib/index.js:95:41
    at next (/home/vince/.node_libraries/.npm/connect- auth/0.2.2/package/lib/strategyExecutor.js:45:39)
    at [object Object].pass (/home/vince/.node_libraries/.npm/connect-auth/0.2.2/package/lib/authExecutionScope.js:18:3)
    at [object Object].halt (/home/vince/.node_libraries/.npm/connect-auth/0.2.2/package/lib/authExecutionScope.js:15:8)
    at [object Object].redirect (/home/vince/.node_libraries/.npm/connect-auth/0.2.2/package/lib/authExecutionScope.js:23:8)
    at /home/vince/.node_libraries/.npm/connect-auth/0.2.2/package/lib/auth.strategies/twitter.js:65:16
@techyak
Copy link

techyak commented Mar 20, 2011

I'm having the same issue - and a similar one with the facebook example.

@phillro
Copy link

phillro commented Mar 27, 2011

Ditto.

@johannesfritsch
Copy link

Same here

@atmos
Copy link
Contributor

atmos commented Mar 29, 2011

Same here with GitHub auth. It still works but the server eventually locks up.

@misterMuyiwa
Copy link

i think your supposed to use res.end not res.send...

@phillro
Copy link

phillro commented Apr 3, 2011

res.end worked.

@gerad
Copy link

gerad commented Jun 24, 2011

I'm getting this with res.render but not with res.end

@ciaranj
Copy link
Owner

ciaranj commented Jul 17, 2011

Implemented in 0.3.0

@ciaranj ciaranj closed this as completed Jul 17, 2011
@atmos
Copy link
Contributor

atmos commented Jul 18, 2011

Haven't tested, but thank you.

@tglines
Copy link

tglines commented Aug 11, 2011

I'm still having this issue as of 0.3.1

@ciaranj
Copy link
Owner

ciaranj commented Aug 11, 2011

Which strategy.. I'm investigating an issue with the google strategy (google seem not to end their connections to json feeds anymore?) ... can you point me at your code at all ?

@tglines
Copy link

tglines commented Aug 11, 2011

The facebook strategy ... I'm not sure if I'm supposed to be trying to redirect in there and whether or not that's what is causing it ...

app.get('/auth/facebook',function(req,res){
  req.authenticate(['facebook'], function(error, authenticated) {
    res.redirect('/');
  });
});

After thinking more about it ... what is likely going on here is that authenticate is sending the headers and I'm trying to add on to them with the redirect ... what is the suggested way to redirect after authenticating?

I ended up replacing it with a javascript redirect.

@ciaranj
Copy link
Owner

ciaranj commented Aug 11, 2011

Ok. So presumably you want to call into loadAccount when a session first successfully authenticates?

The best place to do this is over in your express/connect app or in some middleware... I'd like connect-auth to track first-authenticate and logout as a set of callbacks/events .. but as this doesn't currently exist you just need to do it yourself ...
have you seen: https://github.com/ciaranj/connect-auth/wiki/Example-Basic-Middleware-Implementation-(Facebook) this gives a pretty full implementation of everything I think that you might need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants