使用Share API v2发布到LinkedIn的HTTP响应错误

问题描述

我正在尝试使用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/

之类的隧道软件

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...