Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

342
Visualizações
Implementing google auth using passport - error

I'm trying to implement google sign-in/ sign-up for my web app but I'm getting the following error:

GooglePlusAPIError: Project [project#] is not found and cannot be used  for API calls.

This is my auth setup:

    'googleAuth' : {
        'clientID'       : '***********',
        'clientSecret'   : '***********',
        'callbackURL'    : 'http://localhost:8080/auth/google/callback' 
}

I've created the app on the google developer console and set the redirect URI to the same as that mentioned in the above auth setup. For good measure, here's my strategy for google signup:

passport.use(new GoogleStrategy({

    clientID        :  configAuth.googleAuth.clientID,
    clientSecret    :  configAuth.googleAuth.clientSecret,
    callbackURL     :  configAuth.googleAuth.callbackURL,
},
function(token, refreshToken, profile, done) {
    process.nextTick(function() {

        User.findOne({ 'google.id' : profile.id }, function(err, user) {
            if(err)
                return done(err);

            if(user) {
                // if a user is found log them in
                return done(null, user);
            } else {
                // if no user, create it
                var newUser         = new User();
                newUser.google.id         = profile.id;
                newUser.google.token      = token;
                newUser.google.name       = profile.displayName;
                newUser.google.email      = profile.emails[0].value;

                //save user
                newUser.save(function(err) {
                    if(err)
                        throw err;
                    return done(null, newUser);
                });
            }
        });
    });
}));

I've trawled the internet for answers and find nothing at all. Can anybody help?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Confirm the version of this library that you are using:

https://github.com/jaredhanson/passport-google

The latest version of this library does not accept these options.

See snippet from documentation below:

* Options:
 *   - `returnURL`  URL to which Google will redirect the user after authentication
 *   - `realm`      the part of URL-space for which an OpenID authentication request is valid
 *   - `profile`    enable profile exchange, defaults to _true_
 *
 * Examples:
 *
 *     passport.use(new GoogleStrategy({
 *         returnURL: 'http://localhost:3000/auth/google/return',
 *         realm: 'http://localhost:3000/'
 *       },
 *       function(identifier, profile, done) {
 *         User.findByOpenID(identifier, function (err, user) {
 *           done(err, user);
 *         });
 *       }
 *     ));
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda