我已经遍历了文档和设置,更不用说论坛了。在我的LinkedIn应用程序设置中,这些是我添加的设置。
AuthPage设置
设置页面
JavaScript设置
这可能是因为我使用的是localhost域吗?我见过其他人使用它,但是也许他们以不同的方式使用它。
我的代码(React / JS)
import React, { Component } from 'react';
import './login.scss';
import config from './config';
class Landing extends Component {
// Creates the <script> tag
componentDidMount() {
const e = document.createElement('script');
e.type = 'text/javascript';
e.async = false;
e.src = 'http://platform.linkedin.com/in.js';
const t = document.getElementsByTagName('script')[0];
t.parentNode.insertBefore(e, t);
}
//Trigger Login for LinkedIn
linkedinLogin = () => {
window.IN.init({
api_key: config.linkedin
});
setTimeout(this.getUserDetails, 1000);
}
// Gets the User Information
getUserDetails = () => {
console.log('GetUserDetails');
window.IN.User.authorize(() => {
console.log('Authorizing')
window.IN.API.Profile('me')
.fields(['id', 'firstName', 'lastName', 'pictureUrl', 'publicProfileUrl'])
.result(result => {
console.log(result);
alert(`Successfull login from linkedin : ${result.values[0].firstName} ${result.values[0].lastName}`);
})
.error(err => console.log('Import error - Error occured while importing data'));
window.IN.User.isAuthorized(result => console.log(result));
});
}
render() {
return(
<div className='container'>
<div className='logo'><span>Face</span>timonial</div>
<div className='title-wrapper'>
<h1 className='header'>Best way to get a <br /> recommendation!</h1>
<h2 className='sub-header'>
Facetimonial is a video base recommendation platform and it will
express why you are the best fit for the next job you apply!
</h2>
</div>
<button className='login-btn' onClick={() => this.linkedinLogin()}>
<p>Login With LinkedIn</p>
</button>
</div>
)
}
}
export default Landing;
因此,为了在视图初始化时总结代码,我正在创建linkedin所需的标签。当用户单击该按钮时,它将触发linkedinLogin函数,然后将触发getUserDetails函数。但是,这就是出现问题的地方。我从linkedIn src标记获得功能。但是,它不会授权用户。该错误也无济于事...