【问题标题】:Linkedin API Error {"error_description":"the client is not authorized","error":"unauthorized_client"}Linkedin API 错误 {"error_description":"客户端未授权","error":"unauthorized_client"}
【发布时间】:2015-03-03 18:50:15
【问题描述】:

当我尝试将我的表单从 python 烧瓶提交到 linkedin 时,出现以下异常:{"error_description":"the client is not authorized","error":"unauthorized_client"} 我检查了代码,一切正常。

    post = {
        "grant_type": "authorization_code",
        "code": code,
        "redirect_uri": os.environ["REDIRECT_URI"],
        "client_id": os.environ["API_KEY"],
        "client_secret": os.environ["API_SECRET"]
    }
    access = requests.post("https://www.linkedin.com/uas/oauth2/accessToken", data=post)
    return access.text + str(post)

我所有的环境变量似乎都是正确的。 (我已经检查过多次)但我仍然遇到同样的错误。我也已经在linkedin上注册了该应用程序,并且一直严格遵守文档。有人知道我可能做错了什么吗?

【问题讨论】:

  • 您的 Python 库可能没有以正确的格式发送 POSTed 数据。查看本文档中的第 3 步:developer.linkedin.com/docs/oauth2。请注意 x-www-form-urlencoded 标头要求。

标签: python json api flask linkedin


【解决方案1】:

问题不在于访问代码,而在于 REDIRECT_URI。我之前已经为 get 请求进行了编码,以便它在正确的公式中。但是,该格式对于 POST 请求并不适用。而不是 https%3A%2F%2Fwww.example.com%2Flinkedin 它需要格式化为https://www.example.com/linkedin。这是因为请求库会对参数进行转义,如果已经转义,就会变成双重转义。

【讨论】:

    猜你喜欢
    • 2015-09-29
    • 2017-02-22
    • 1970-01-01
    • 1970-01-01
    • 2021-01-07
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多