2017-04-26 3 views
0

私は自分のWebアプリケーションのためのGoogleはサインイン/サインアップを実装しようとしているが、私は次のエラーを取得しています:はパスポートを使用してAUTHグーグルの実装 - エラー

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

これは私の認証の設定です:

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

私はGoogle開発者向けのコンソールでこのアプリケーションを作成し、リダイレクトURIを上記の認証設定で述べたものと同じに設定しました。良い測定のために、ここではGoogleのサインアップのための私の戦略です:

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); 
       }); 
      } 
     }); 
    }); 
})); 

私は答えを、インターネットをトロールとは全く何も見つかりませんしました。誰でも助けることができますか?

答えて

0

使用しているこのライブラリのバージョンを確認します。このライブラリの最新バージョンは、これらのオプションを受け入れない

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

を。

以下のドキュメントから参照スニペット:このため

* 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); 
*   }); 
*  } 
* )); 
+0

おかげで、問題ではないようです。私が受け取ったエラーはこれをまったく指摘しておらず、「callbackURL」を何か他のものに置き換えるとすぐに、私はこのパラメータが足りないことを知らせます – DaveB1

+0

あなたはどのライブラリのバージョンを使用していますか? – ifiok

+0

それは3.10.10 ... – DaveB1

関連する問題