【问题标题】:LinkedIn API: The token used in the OAuth request has been revokedLinkedIn API:OAuth 请求中使用的令牌已被撤销
【发布时间】:2014-10-18 17:41:25
【问题描述】:

我在使用 linkedin V1 API 时收到以下错误:

response body: {
  "errorCode": 0,
  "message": "[unauthorized]. The token used in the OAuth request has been revoked. 75--5cfb9cdb-3c9c-47c2-b3f8-XXXXXXXX",
  "requestId": "I2GQ0ZMWIE",
  "status": 401,
  "timestamp": 1408976297742
}

我在这里使用本指南,我正在做这个人正在做的事情,但我得到了不同的结果:

https://github.com/PrincessPolymath/LinkedIn-OAuth-Sample-Client

我不知道为什么会收到 OAuth 请求中使用的令牌已被撤销。 错误。 HTTP 请求是相同的。会不会是我的捆绑包 ID?

我无法从linkedin 中找到有关此事的任何信息。为什么linkedin不像其他API那样有正常的错误代码查找。

这是两个请求对象的一些照片,一张来自示例,一张来自我的。

【问题讨论】:

    标签: ios api oauth linkedin


    【解决方案1】:

    根据我对您描述的问题的理解,我在这里猜测,尚未对此进行测试。我还假设您的凭据正确...

    您应该查看 Kamyar Mohager (#39) 的 this answer,他解释了如何绕过此错误:

    When obtaining access token, error occurs if:
    
    POST https://www.linkedin.com/uas/oauth2/accessToken
    
    Body:
    {
    grant_type=authorization_code,
    code={auth-code},
    redirect_uri={uri},
    client_id={id},
    client_secret={secret}
    }
    
    The error WON'T occur if you obtain the access token by passing the params as query params:
    
    POST https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code={auth-code}&redirect_uri={uri}&client_id={id}&client_secret={secret}
    

    【讨论】:

      【解决方案2】:

      错误清楚地表明用户有权使用您正在使用的令牌进行呼叫。

      "message": "[unauthorized]. The token used in the OAuth request has been revoked. 75--5cfb9cdb-3c9c-47c2-b3f8-XXXXXXXX",
      

      在您上面粘贴的两张照片中,我可以看到您的请求对象具有与示例请求对象不同的值“tokenKey 和 tokenSecret”参数,这是正确的,因为您的请求应该具有从 LinkedIn 接收的令牌信息。

      但我不明白的是,为什么两个请求对象的“consumeKey 和 consumerSecret”参数具有相同的值。我认为您需要使用您的“consumerKey & consumerSecret”和“tokenkey & tokensecret”来进行此 OAuth 调用。 "consumer" 和 "token" 详细信息组合应该匹配,然后只有您才能进行成功的 oauth 调用。

      我猜您看到此错误是因为您将令牌与其他消费者密钥一起使用。

      我可以看到您在请求对象中传递“验证程序”的另一件事,因此我想知道您是否正在调用获取“访问令牌”,这是 oauth 的第三条腿。如果是,那么在您进行此“access_token”调用之前可能会出现“requestToken”已过期的情况,因为“requestToken”实际上是一个“临时令牌”并且会很快过期。

      HTH...

      【讨论】:

      • 记住我使用的是例子,它负责构造这个对象。这一切都应该在 oAuth 的第三站之后。它也发生在示例中。这是linkedin的版本问题,V1过时了吗?
      【解决方案3】:

      问题在于代码重用。

      如 API 的 cmets 中所述,API 将在第一次请求时为您提供令牌和密码。这只发生在认证过程中,然后token和secret基本上可以扔掉,可以使用developer.linkedin的那个issue。

      我通过构建自己的请求对象而不是依赖 oAuth 过程中的旧 HTTPRequestBody 来解决此问题。

      【讨论】:

        猜你喜欢
        • 2019-03-25
        • 1970-01-01
        • 1970-01-01
        • 2017-10-03
        • 1970-01-01
        • 2022-06-17
        • 1970-01-01
        • 1970-01-01
        • 2020-11-13
        相关资源
        最近更新 更多