问题描述
我正在尝试使用OAuth v2将共享发布到LinkedIn-我已正确获得授权并具有适当的访问密钥。 该代码应该在LinkedIn上共享一个链接,但是由于某些原因,它无法正常工作-我不确定为什么。有人可以帮忙吗? 这是我的请求正文:
{
"distribution": {
"linkedindistributionTarget": {}
},"owner": "urn:li:person:XXXXXX","subject": "Test Share Subject","text": {
"text": "Hello !"
}
这与我的呼叫API共享:
publishPostLink(body : any,token : any){
this.headers = new HttpHeaders(
{
'Content-Type': 'application/json','Authorization':'Bearer '+token,'cache-control': 'no-cache','X-Restli-Protocol-Version':'2.0.0',});
return this.http.post("https://api.linkedin.com/v2/shares",body,{headers: this.headers});}
我遇到了这个问题:
I've already installed the Moesif CORS and it didn't worked
我通过这篇文章修正了错误。 it should use REST API from the backend and not from frontend
解决方法
http:// localhost是不安全的请求来源,因此在许多情况下不支持它。 尝试使用Ngork https://ngrok.com/
之类的隧道软件