【问题标题】:403 Forbidden Access to posting shares denied for Linkedin API using python-linkedin library403 禁止访问使用 python-linkedin 库为 Linkedin API 拒绝发布共享
【发布时间】:2019-03-23 16:08:39
【问题描述】:

我是使用 Linkedin API 的新手,我正在尝试使用 python-linkedin 库发布到 LinkedIn:https://github.com/ozgur/python-linkedin

我们使用 Auth0 进行身份验证。 我可以获取个人资料信息。但是,我在尝试使用 Share API 发帖时收到 403 错误。

在 shell 中测试 get profile 的工作原理:

In []: linkedin_api.get_profile()
Out[]:
{'firstName': '*my name*',
 'headline': '*my headline*',
 'id': '*my id*',
 'lastName': '*my lastname*',
 'siteStandardProfileRequest': {'url': 'https://www.linkedin.com/profile/view?id=*CONFIDENTIAL*&authType=name&authToken=*CONFIDENTIAL*'}}

但是当我尝试发布到linkedin时:

In []: linkedin_api.submit_share('Test posting
...: from the API I am working on using JSON'
...: , 'A title for your share', None, 'http:
...: //www.linkedin.com', 'http://d.pr/3OWS')

这会导致 403 客户端错误

LinkedInForbiddenError: 403 Client Error: Forbidden for url: 
https://api.linkedin.com/v1/people/~/shares?
oauth2_access_token=*CONFIDENTIAL*: Access to posting shares denied

【问题讨论】:

  • 您是否正确生成了访问令牌?这会导致这些问题
  • 应该是正确的。我按照这里的步骤:stackoverflow.com/questions/37115035/… 验证访问令牌是否正常工作。此外,通过获取关联的 Auth0 Linkedin 配置文件然后检索访问令牌,使用 auth0 生成访问令牌,因此由于它由 Auth0 处理,我认为不会有问题。我检查了 Auth0 以确保权限设置也正确
  • 其实我觉得你可能是对的。我刚刚尝试在共享路由 https://api.linkedin.com/v1/people/~/shares/?oauth2_access_token=*Confidential* 而不是配置文件路由上进行身份验证,但我被拒绝访问!我将研究为什么会这样,如果我发现任何东西就会发布

标签: python django python-3.x linkedin linkedin-api


【解决方案1】:

找出问题所在。

我需要在我的 auth0 锁中添加 w_share 范围,以便我可以访问linkedin Share api。

这是一个帮助我的问题的链接:https://community.auth0.com/t/linkedin-w-share-permission/12386/2

我将 connectionScopes 参数添加到 auth0 锁定选项中,从而解决了问题:

connectionScopes: {
    linkedin: ["w_share"]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 2015-06-13
    相关资源
    最近更新 更多