2014-02-19 55 views
0

我正在嘗試使用oauth2-server-php爲網站實現自定義OAuth2提供程序,以使用Passport來認證node.js客戶端。應如何提供Profile信息以便Passport.js可以使用它?

實施的端點(例如,授權,令牌)幾乎與this oauth2-server-php tutorial中所描述的相同。

在我的Node.js應用程式,我用護照的戰略的oauth2使用類似於此的配置(從護照文檔):

passport.use(new OAuth2Strategy({ 
    authorizationURL: 'https://www.example.com/oauth2/authorize', 
    tokenURL: 'https://www.example.com/oauth2/token', 
    clientID: EXAMPLE_CLIENT_ID, 
    clientSecret: EXAMPLE_CLIENT_SECRET, 
    callbackURL: "http://localhost:3000/auth/example/callback" 
    }, 
    function(accessToken, refreshToken, profile, done) { 
    User.findOrCreate({ exampleId: profile.id }, function (err, user) { 
     return done(err, user); 
    }); 
    } 
)); 

正如你可以看到,它處理與function(accessToken, refreshToken, profile, done)接收到的信息。

而我的問題是:我需要如何提供(在我的自定義oauth2提供程序中)profile參數,因此Passport可以訪問它嗎?它在哪裏恰恰是從何而來?

回答

相關問題