【问题标题】:unable to retrieve access token linkedin api无法检索访问令牌linkedin api
【发布时间】:2018-06-21 06:36:22
【问题描述】:

我正在申请connect with linkedin。我正在关注step by step guide。为了对用户进行身份验证,我从 this 那里得到了帮助。

当用户单击connect with linkedin 按钮时,用户将被带到linkedin 登录页面。在用户授予对帐户的访问权限后,用户将被重定向到:

https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=1ba8ogpm9e05&scope=r_basicprofile%20r_emailaddress&state=STATE&redirect_uri=http://127.0.0.1:8088/sandbox/linkedin/test.php

通过这个,我得到了授权码。并将其传递到以下 url

https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=AUTHORIZATION_CODE&redirect_uri=http://127.0.0.1:8088/sandbox/linkedin/final.php&client_id=1ba8ogpm9e05&client_secret=n7GN09I3F2L3IJD1

这里,错误来了,即

"error":"invalid_request","error_description":"missing required parameters, includes an invalid parameter value, parameter more then once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired"

我哪里错了?我已经仔细检查了我的 api 密钥和密钥。

【问题讨论】:

  • linkedin.com/uas/oauth2/… 您已将 AUTHORIZATION_CODE 放在需要的地方,对吧?让我知道你是否做得正确..
  • 是的,我传递了正确的授权码

标签: php linkedin


【解决方案1】:
https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=AUTHORIZATION_CODE&redirect_uri=http://127.0.0.1:8088/sandbox/linkedin/final.php&client_id=1ba8ogpm9e05&client_secret=n7GN09I3F2L3IJD1
https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=1ba8ogpm9e05&scope=r_basicprofile%20r_emailaddress&state=STATE&redirect_uri=http://127.0.0.1:8088/sandbox/linkedin/test.php

根据LinkedIn authentication guide,这两者应该包含相同的redirect_uri

参数:redirect_uri
说明:必填。与您在上一步中传递的 redirect_uri 相同。
可能的错误:

  • redirect_uri 与生成授权码时使用的不同
  • 传递的值无效
  • 传递了一个空值或空白值
  • 缺少参数

【讨论】:

  • 我也是这种情况,除了我使用相同的转义redirect_uri,但是当我使用非转义的redirect_uri时它通过了!
  • @mkhatib 嗨,当我在授权和 accessToken 端点中使用相同的重定向 uri 时,我得到了无效的 redirect_uri。我尝试使用带和不带编码的网址。编码的 url 给了我无效的 redirect_uri 错误,而没有编码的 url 给了我无效的请求错误。请帮忙。
【解决方案2】:

我遇到了和你一样的错误。我还满足了以下条件:

  • 我的请求是 POST 请求。
  • 我的redirect_uri/authorization/accessToken 通话中的相同。
  • /accessToken 调用在收到授权码后立即执行,所以 它不会过期。

最终对我有用的是撤销在https://www.linkedin.com/secure/developer 的应用程序详细信息页面上生成的访问令牌。

这是 oAuth 1.a 的访问令牌,与当前运行 linkedIn api 的 oAuth 2.0 不兼容。
撤销此访问令牌后,我可以通过 /authorization/accessToken 调用获得一个新的。

【讨论】:

  • 我面临同样的问题,但我不明白您是如何撤销在应用程序页面上生成的访问令牌的?你能帮我吗?我正在使用相同的redirectUri,仍然遇到同样的问题
【解决方案3】:

您可能还需要确保将访问令牌请求作为“POST”发送

【讨论】:

  • 你能告诉我,我只发出 POST 请求,但需要在标头中发送什么?在体内也是如此
猜你喜欢
  • 1970-01-01
  • 2018-03-01
  • 2020-02-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-28
相关资源
最近更新 更多