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

Facebook auth id is not used from local.env.js with built project. #513

Closed
gintsgints opened this issue Sep 2, 2014 · 10 comments
Closed
Labels

Comments

@gintsgints
Copy link
Contributor

I execute:

npm cache clear
npm update -g generator-angular-fullstack
yo angular-fullstack tst

update server/config/local.env.js with correct infos.

grunt serve

Facebook auth works.

set NODE_ENV=production <- windows
grunt build
cd dist
npm install
node server/app.js

and after connection to application facebook auth sends to:

https://www.facebook.com/dialog/oauth?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth%2Ffacebook%2Fcallback&scope=email%2Cuser_about_me&client_id=id

How to get cliend_id fill correctly?

@remicastaing
Copy link
Contributor

You have to fill local.env.js:

FACEBOOK_ID:      '??????????????',
FACEBOOK_SECRET:  '????????????????',

or have to set the environnemental variable process.env.FACEBOOK_IDand process.env.FACEBOOK_SECRET.

@JaKXz JaKXz added the question label Sep 2, 2014
@gintsgints
Copy link
Contributor Author

For sure. I have filled local.env.js with correct values. (As I mentioned local started facebook auth works)

@kingcody
Copy link
Member

kingcody commented Sep 3, 2014

@gintsgints are you asking about: &client_id=id?

@gintsgints
Copy link
Contributor Author

yes.

@kingcody
Copy link
Member

kingcody commented Sep 3, 2014

Does server/config/environment/index.js contain:

  facebook: {
    clientID:     process.env.FACEBOOK_ID || 'id',
    clientSecret: process.env.FACEBOOK_SECRET || 'secret',
    callbackURL:  (process.env.DOMAIN || '') + '/auth/facebook/callback'
  }

If so, thats where config.facebook.clientID gets set to process.env.FACEBOOK_ID. Then in server/auth/facebook/passport.js you should see:

  passport.use(new FacebookStrategy({
      clientID: config.facebook.clientID,
      clientSecret: config.facebook.clientSecret,
      callbackURL: config.facebook.callbackURL
    }

Which is where passport is configured to use config.facebook.clientID as the clientID.

Does this help with your question?

@gintsgints
Copy link
Contributor Author

Actualy I think that this is not question but bug.
I would expect that if I provide local.env.js file for bulid process, then builded app should be able to connect facebook, same like with "grunt serve".
I think that

process.env.FACEBOOK_ID

is not set with builded app. (as opposite to process.env.DOMAIN)

@gintsgints
Copy link
Contributor Author

If I replace in ``dist/server/config/environment/index.js`:

clientID:     process.env.FACEBOOK_ID || 'id',
clientSecret: process.env.FACEBOOK_SECRET || 'secret',

'id' and 'secret' with real values. Then everything works.

@kingcody
Copy link
Member

kingcody commented Sep 3, 2014

I see. I actually miss read your OP. local.env.js is used by Grunt to set environment variables for you. When not using grunt you'll need to set them when you run node server/app.js or require local.env.js at the top of app.js

Hope this helps.

@kingcody
Copy link
Member

kingcody commented Sep 3, 2014

Actually there are tons of ways to set environment variables, those are just a few that I mentioned.

@gintsgints
Copy link
Contributor Author

If setting enviroment variables is how it is supposed to work. Then question is answered.

Thanks.

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

No branches or pull requests

4 participants