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

How do I make this work!? #1

Open
kristianmandrup opened this issue Aug 24, 2015 · 4 comments
Open

How do I make this work!? #1

kristianmandrup opened this issue Aug 24, 2015 · 4 comments

Comments

@kristianmandrup
Copy link

I start the server using iojs 3.0

node app.js or node --harmony app.js

Then go to localhost:3000/app but I always get a 404 error.

passport.use(new GithubStrategy({
    clientID: 'kristianmandrup',
    clientSecret: 'MySecretPassword',
    callbackURL: "http://localhost:3000/auth/github/callback"
  },

Also tried testing via supertest

app.listen(3000, function() {
  console.log('listening 3000');
});

console.log('testing...');

let agent = require('supertest-koa-agent');
let agentApp = agent(app);

function user(name, password) {
  return {username: name, password: password};
}

var users = {
  valid: user('freddyucv', 'secret123'),
  invalid: user('johndoe', 'secret')
};

function *loginTest() {
  console.log('do test: /login');
  var res = yield agentApp.post('/login').send(users.valid).end();
  expect(res.status).to.eql(200);
}
console.log('ready!');
loginTest();

but logingTest never logs the message even :(

@kristianmandrup
Copy link
Author

Ah, I forgot to create the app on github. Now I use the tokens given to me by github for the tutorial app.

2015-08-24T16:12:38.650Z - GET /favicon.ico
2015-08-24T16:12:42.395Z - GET /app
2015-08-24T16:12:42.402Z - GET /auth/github
2015-08-24T16:13:14.477Z - GET /auth/github/callback?code=1d3c54ea5dfa4e858ae9
token 9744eed916a4a8ba2b93ef62a1454763ede0f297
TypeError: Cannot set property 'user' of undefined
    at /Users/kristianmandrup/repos/graphql/koa-tutorial-authenticate-with-persistent-session-using-redis/node_modules/passport-github/node_modules/passport-oauth/node_modules/passport/lib/passport/http/request.js:45:35
    at pass (/Users/kristianmandrup/repos/graphql/koa-tutorial-authenticate-with-persistent-session-using-redis/node_modules/koa-passport/node_modules/passport/lib/authenticator.js:267:43)
    at serialized (/Users/kristianmandrup/repos/graphql/koa-tutorial-authenticate-with-persistent-session-using-redis/node_modules/koa-passport/node_modules/passport/lib/authenticator.js:276:7)
    at /Users/kristianmandrup/repos/graphql/koa-tutorial-authenticate-with-persistent-session-using-redis/auth.js:22:3
    at pass (/Users/kristianmandrup/repos/graphql/koa-tutorial-authenticate-with-persistent-session-using-redis/node_modules/koa-passport/node_modules/passport/lib/authenticator.js:284:9)

@Zev23
Copy link
Owner

Zev23 commented Sep 1, 2015

Hi @kristianmandrup, do you still facing the problem of getting authorized?

@kristianmandrup
Copy link
Author

Yes, I left the project to come back to it later... any ideas?

@Zev23
Copy link
Owner

Zev23 commented Sep 3, 2015

From the log it seems like the request object is not found (this.req.user).
Are you running this project itself or using supertest-koa-agent?
Have you tried just running this project in nodejs with all the specific package version in package.json?

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

2 participants