2016-10-20 12 views
1

ユーザの電子メールとパスワードを提供することにより、ノードリンクパッケージを使用するためにアクセストークンを取得することは可能ですか?私がしようとしているのは、linkinにapi呼び出しを行い、結果をテキストファイルに書き込むコマンドラインアプリです。したがって、私はクライアントにapiの呼び出し結果を送信していません。メールアドレスとパスワードを使用してLinkedin APIへのアクセストークンを取得

答えて

1

私は同じことをやろうとしています。

simple-oauth2モジュールにはパスワードでログインする方法がありますが、動作させることができません。

https://www.npmjs.com/package/simple-oauth2

// Set the configuration settings 
const credentials = { 
    client: { 
    id: '<client-id>', 
    secret: '<client-secret>' 
    }, 
    auth: { 
    tokenHost: 'https://api.linkedin.com', 
    authorizePath: 'https://api.linkedin.com/uas/oauth/requestToken', 
    tokenPath: 'https://api.linkedin.com/uas/oauth/accessToken' 
    } 
}; 

// Initialize the OAuth2 Library 
const oauth2 = require('simple-oauth2').create(credentials); 

// Get the access token object. 
const tokenConfig = { 
    username: 'username', 
    password: 'password' 
}; 

// Callbacks 
// Save the access token 
oauth2.ownerPassword.getToken(tokenConfig, (error, result) => { 
    if (error) { 
    return console.log('Access Token Error', error.message); 
    } 

    const token = oauth2.accessToken.create(result); 
}); 

私は、これらのエンドポイントが正しいか確認していない:

auth: { 
    tokenHost: 'https://api.linkedin.com', 
    authorizePath: 'https://api.linkedin.com/uas/oauth/requestToken', 
    tokenPath: 'https://api.linkedin.com/uas/oauth/accessToken' 
    } 

私は400不正な要求を取得します。

+0

答えに感謝します!現在のところ私はこれを再現することができないので、もし誰かがこの答えが役に立つと分かったら、私はそれを最も役立つものとしてマークします! – mcmxc

+0

@mcmxcあなたはこれらの 'auth'エンドポイントがあなたのために働くと言っていますか? – chovy

+0

実際には私がそれをチェックすることは不可能であるので、あなたの答えはあなたのために期待どおりに機能し、私の問題を解決します。 – mcmxc

関連する問題