Skip to content Skip to sidebar Skip to footer

Meteor.user Is Null After (apparently) Successful Login

I have a simple Meteor js app that allows you to create a user account and log in, or to log in with your existing Google account via oauth (thanks to the accounts-google package).

Solution 1:

You probably messed up oauth configuration either on the Meteor side or Google Developers Console side, so here is a quick recap.

Google Developers Console :

Under APIs & auth > Credentials, create a new Client ID in the OAuth section.

Choose Web Application and specify both correct redirect URIs and JavaScript origins :

REDIRECT URIS

http://localhost:3000/_oauth/google?close
http://your-production-domain.com/_oauth/google?close

JAVASCRIPT ORIGINS

http://localhost:3000
http://your-production-domain.com

Meteor configuration :

Be sure to add these packages :

meteor add accounts-google
meteor add service-configuration

In server/config.js, add these lines from http://docs.meteor.com/#meteor_loginwithexternalservice

ServiceConfiguration.configurations.remove({
  service: "google"
});
ServiceConfiguration.configurations.insert({
  service: "google",
  clientId: "????????????????.apps.googleusercontent.com",
  secret: "????????????????"
});

The clientId and secret fields should be set to those in the Google Developers Console.

Then call Meteor.loginWithGoogle() in the click handler of your login form and it should work as expected.

Post a Comment for "Meteor.user Is Null After (apparently) Successful Login"