LinkedIn Javascript SDK API“;“哦”;错误弹出窗口
我不断地从linkedin登录弹出窗口中得到“uh-oh”错误。 我已经看过了文档和设置,更不用说论坛了。在我的LinkedIn应用程序设置中,这些是我添加的设置 授权页面设置 设置页面 Javascript设置 这可能是因为我使用的是本地主机域吗?我见过其他人使用它,但也许他们使用它的方式不同 我的代码(React/JS)LinkedIn Javascript SDK API“;“哦”;错误弹出窗口,javascript,oauth,oauth-2.0,linkedin-api,Javascript,Oauth,Oauth 2.0,Linkedin Api,我不断地从linkedin登录弹出窗口中得到“uh-oh”错误。 我已经看过了文档和设置,更不用说论坛了。在我的LinkedIn应用程序设置中,这些是我添加的设置 授权页面设置 设置页面 Javascript设置 这可能是因为我使用的是本地主机域吗?我见过其他人使用它,但也许他们使用它的方式不同 我的代码(React/JS) import React,{Component}来自'React'; 导入“/login.scss”; 从“/config”导入配置; 类扩展组件{ //创建标记
import React,{Component}来自'React';
导入“/login.scss”;
从“/config”导入配置;
类扩展组件{
//创建标记
componentDidMount(){
const e=document.createElement('script');
e、 类型='text/javascript';
e、 异步=假;
e、 src='1〕http://platform.linkedin.com/in.js';
const t=document.getElementsByTagName('script')[0];
t、 parentNode.insertBefore(e,t);
}
//触发LinkedIn的登录
LinkedIn登录=()=>{
window.IN.init({
api_密钥:config.linkedin
});
setTimeout(this.getUserDetails,1000);
}
//获取用户信息
getUserDetails=()=>{
log('GetUserDetails');
window.IN.User.authorize(()=>{
console.log('Authorizing')
window.IN.API.Profile('me')
.fields(['id','firstName','lastName','pictureUrl','publicProfileUrl']))
.result(结果=>{
控制台日志(结果);
警报(`Successfull login from linkedin:${result.values[0].firstName}${result.values[0].lastName}`);
})
.error(err=>console.log(“导入错误-导入数据时出错”);
window.IN.User.isAuthorized(结果=>console.log(结果));
});
}
render(){
返回(
刻面年画
获得
推荐的最佳方式!
Facetimonial是一个基于视频的推荐平台,它将
表达为什么你最适合你申请的下一份工作!
this.linkedinLogin()}>
使用LinkedIn登录
)
}
}
导出默认着陆;
因此,为了总结视图初始化时的代码,我正在创建linkedin需要的标记。当用户单击该按钮时,它将启动linkedinLogin函数,然后启动getUserDetails函数。然而,这正是问题出现的地方。我从linkedIn src标记获取函数。但是它不会授权用户。这个错误也没有帮助
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;