【问题标题】:Getting Invalid Access Token error after authorizing via omniauth-linkedin通过omniauth-linkedin授权后出现无效访问令牌错误
【发布时间】:2014-12-20 05:05:27
【问题描述】:

调用配置文件API时出现Following错误

{
 errorCode: 0
 message: "Invalid access token."
 requestId: "7PQ0XX5WYL"
 status: 401
 timestamp: 1418976605501
}

授权用户并通过https://github.com/skorks/omniauth-linkedin获取access_token后查询时

我的查询看起来像

GET https://api.linkedin.com/v1/people/~?oauth2_access_token=8d8bb5ad-XXX-9026cde508b6-XXX

还尝试在标头中传递令牌,如 https://developer.linkedin.com/documents/authentication 中所述,第 4 步。发出经过身份验证的请求

作为

获取https://api.linkedin.com/v1/people/~

Connection: Keep-Alive
Authorization: Bearer 8d8bb5ad-XXX-9026cde508b6-XXX
Host: api.linkedin.com
x-li-format: json 

我的响应头看起来像

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)        Chrome/38.0.2125.101 Safari/537.36
Authorization: Bearer 8d8bb5ad-XXX-9026cde508b6-XXX
x-li-format: json
Accept: */*
Accept-Encoding: gzip,deflate

我也在linkedin开发者网站https://developer.linkedin.com/forum/invalid-access-token上提到了这个问题,但没有更新(不完整的线程)

我是不是做错了什么,有什么想法吗?

【问题讨论】:

  • 我也遇到了同样的错误,你找到解决办法了吗?
  • @Dibish 我使用 OAuth 1.0 进行身份验证流程,当我使用 github.com/decioferreira/omniauth-linkedin-oauth2 gem 通过 OAuth 2.0 对用户进行身份验证时,我在使用新令牌时得到了新令牌错误得到解决。

标签: ruby-on-rails-3 ruby-on-rails-4 oauth-2.0 linkedin omniauth


【解决方案1】:

在大多数情况下,此错误消息可能是由于为经过身份验证的用户提供了更新的访问令牌,这使您在问题中提到的访问令牌无效。如果您要让用户再次通过 OAuth 2.0 流程并尝试使用新的访问令牌进行经过身份验证的调用,您是否仍然收到相同的错误?

【讨论】:

  • 我也尝试再次通过 OAuth 2.0 流程重新授权用户,我再次得到相同的访问令牌和相同的错误,这个访问令牌有 2 个月的生命周期,所以每次重新授权都会获得相同的令牌用于授权用户
  • 已解决:我使用 OAuth 1.0 进行身份验证流程,当我使用 github.com/decioferreira/omniauth-linkedin-oauth2 gem 通过 OAuth 2.0 对用户进行身份验证时,我在使用新令牌时得到了新令牌错误解决了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-13
  • 2019-07-22
  • 1970-01-01
  • 1970-01-01
  • 2012-09-04
  • 1970-01-01
相关资源
最近更新 更多