【发布时间】:2018-08-04 20:07:29
【问题描述】:
我希望我的用户使用 使用 LinkedIn 登录 功能登录。 LinkedIn API 文档提供了以下示例 sn-p 以供入门:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: YOUR_API_KEY_HERE
authorize: true
onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Handle the successful return from the API call
function onSuccess(data) {
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
IN.API.Raw("/people/~").result(onSuccess).error(onError);
}
</script>
如何在不向公众公开 YOUR_API_KEY_HERE 的情况下实现这一点?有一些 npm 包可以处理这种事情,但它们都很旧(每当一个包至少一年没有更新时,我都会感到紧张)。
我的应用程序使用 node 和 express。我应该使用旧的 npm 包还是有更好的方法来隐藏 api_key?
【问题讨论】:
标签: javascript node.js express oauth-2.0 linkedin-api