AVGP / cloud9hub

A workspace dashboard for Cloud9
97 stars 47 forks source link

500 failed to fetch user profile #3

Closed JeffWScott closed 10 years ago

JeffWScott commented 10 years ago

I followed your instructions but I get this error after going to myserver.my.server:3000 and clicking the "sign in with GitHub" link. Obviously I'm doing something wrong but I can't figure out what.

Express 500 failed to fetch user profile (status: 401 data: {"message":"Requires authentication","documentation_url":"http://developer.github.com/v3"}) at /home/jeff/cloud9/cloud9hub/node_modules/passport-github/lib/passport-github/strategy.js:90:28 at passBackControl (/home/jeff/cloud9/cloud9hub/node_modules/passport-github/node_modules/passport-oauth/node_modules/oauth/lib/oauth2.js:109:9) at IncomingMessage. (/home/jeff/cloud9/cloud9hub/node_modules/passport-github/node_modules/passport-oauth/node_modules/oauth/lib/oauth2.js:128:7) at IncomingMessage.EventEmitter.emit (events.js:117:20) at _stream_readable.js:920:16 at process._tickCallback (node.js:415:13)

When I setup the app in Github I wasn't sure what to put for "Authorization callback URL" so I put "myserver.my.server".

I don't know a whole lot about oAuth. if this is the issue can you please point me in the right direction?

AVGP commented 10 years ago

Seems to be somewhat related to oAuth. I am not sure if it's the callback URL tho. But let's try that - you definitely spotted a hole in the docs (thx for pointing it out): In the Github application settings set the callback URL to http://myserver.my.server://3000/auth/github/callback and try again. If that doesn't fix it, we'll dig deeper

JeffWScott commented 10 years ago

I think your instructions are probably great for people that know what's going on. Unfortunately when you post stuff on the internet you get people like me who are just fumbling around trying to get things to work :) If I'm wasting your time just let me know!

"http://myserver.my.server://3000/auth/github/callback" did not work at all, said could not find page.

I changed it to "http://myserver.my.server:3000/auth/github/callback" and I got the same error as before; the 500 error.

JeffWScott commented 10 years ago

Also, a quick question. Does your cloud9hub start-up my cloud9 server? meaning, do I need to startup both your server.js and the server.js in the "c9" directory?

AVGP commented 10 years ago

Oh boy the autocorrect fooled me once more.

The fact that the docs need to become more expressive is true. TThat's why I work to improve them :)

Alright so that wasn't the cause for the server error... Give me some time to find other options

AVGP commented 10 years ago

It starts cloud9 automatically for you

AVGP commented 10 years ago

It could be related to an invalid Client Secret or Client ID.

stealthdave commented 10 years ago

I'm having the same issue. Exact same error, presumably same setup. My relevant settings in the GitHub Application are:

Homepage URL: http://cloud9.myserver.com:3000 Authorization callback URL: http://cloud9.myserver.com:3000/auth/github/callback

Log output follows (slightly sanitized):

GET /auth/github/callback?code={token} 500 921ms
failed to fetch user profile (status: 401 data: {"message":"Requires authentication","documentation_url":"http://developer.github.com/v3"})
    at /var/www/cloud9hub/cloud9hub/node_modules/passport-github/lib/passport-github/strategy.js:90:28
    at passBackControl (/var/www/cloud9hub/cloud9hub/node_modules/passport-github/node_modules/passport-oauth/node_modules/oauth/lib/oauth2.js:109:9)
    at IncomingMessage.<anonymous> (/var/www/cloud9hub/cloud9hub/node_modules/passport-github/node_modules/passport-oauth/node_modules/oauth/lib/oauth2.js:128:7)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:910:16
    at process._tickCallback (node.js:415:13)
stealthdave commented 10 years ago

SOLVED! It's obvious once you see it, but it's an issue with the config.js. Make sure that you set your exports.PERMITTED_USERS correctly. By default, only GitHub users 'alice' and 'bob' will be able to use your application! Change it thusly:

exports.GITHUB_CLIENT_ID = '{client_id}';
exports.GITHUB_CLIENT_SECRET = '{client_secret}';
// This allows everybody to sign up
//exports.PERMITTED_USERS = false; // comment this line out
// This restricts signup to the users alice and bob:
//exports.PERMITTED_USERS = ['alice', 'bob']; // comment this line out, too
exports.PERMITTED_USERS = ['steathdave'];
exports.BASE_URL = 'http://localhost';

After this change, I am able to log into my application.

AVGP commented 10 years ago

@stealthdave Nice catch! I think the permitted users should be commented out by default, only to be enabled when you really want it... I'll change that and make a note in the readme

AVGP commented 10 years ago

But wait - it should ignore the permitted users when it's set to false (as is in the default config.js.example)