meteor.js を実行しており、npm パッケージをグローバルにインストールしていますnode-linkedin
https://www.npmjs.com/package/node-linkedin
アプリケーションをlinkedinに登録しました。これは、APIキー、秘密鍵、およびoAuthリダイレクトURLをlocalhost:3000に持っていることを意味します
私のアプリは現在、ユーザーが私のアプリケーションにユーザーの完全なプロファイルへのアクセスを許可する「サインイン」のlinkedInボタンを表示しています。linkedIn javascript API docs によると、onLinkedInAuth()
オブジェクト (認証が成功したときに実行される) には、ユーザーの linkedin IDが含まれています。
Accounts.createUser
ユーザーが認証され、onLinkedInAuth() オブジェクトからのIDをユーザー コレクションに保存するときに、ユーザー アカウントを作成するにはどうすればよいですか?
サーバー.js
var Linkedin = Npm.require('node-linkedin')('api', 'secret', 'I-PUT-REDIRECT-URL-HERE');
npm パッケージhttps://www.npmjs.com/package/node-linkedin (oAuth 2.0 の見出しの下を参照) を使用して get リクエストを行うにはどうすればよいですか。
HTML:
<head>
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: *MY_API_KEY*
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
// Runs when the JavaScript framework is loaded
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
}
// Runs when the viewer has authenticated
function onLinkedInAuth() {
IN.API.Profile("me")
.result( function(me) {
var id = me.values[0].id;
// AJAX call to pass back id to your server
});
}
// Runs when the Profile() API call returns successfully
function displayProfiles(profiles) {
member = profiles.values[0];
document.getElementById("profiles").innerHTML =
"<p id=\"" + member.id + "\">Hello " + member.firstName + " " + member.lastName + "</p>";
}
</script>
</head>
<template name="parent"> //layout template
<!-- Displays a button to let the viewer authenticate -->
<script type="IN/Login" data-onAuth="onLinkedInAuth"></script>
<!-- Placeholder for the greeting -->
<div id="profiles"></div>
</template>