Unable to access Linkedin profile with valid oauth2 access token

こ雲淡風輕ζ 提交于 2019-12-10 10:19:03

问题


I am having the same problem that is described in LinkedIn OAuth2: "Unable to verify access token"; however, the solution described there does not fix my problem.

I am able to successfully request an access token; however, when I make a request with it (using either the Authorization header or the oauth2_access_token query param), I get a 401 failure:

$ curl "https://api.linkedin.com/v1/people/~?format=json&oath2_access_token=############"
{
  "errorCode": 0,
  "message": "Unable to verify access token",
  "requestId": "Z9ZJ1MOUM0",
  "status": 401,
  "timestamp": 1440096560396
}
$curl --header  "Authorization: Bearer #############" 'https://api.linkedin.com/v1/people/~?format=json'
{
  "errorCode": 0,
  "message": "Unable to verify access token",
  "requestId": "Y1P2PEBEC3",
  "status": 401,
  "timestamp": 1440096564518

The strange thing about this is:

  1. This problem doesn't surface if the user is logged into Linkedin.

  2. If you wait five minutes, the request will just start working.

My guess this is a bug in Linkedin about latency of authorizing access codes based the users' logged in state, but I don't know.

Also I find it strange that the Linkedin authorization form reads, "Sign in to LinkedIn and allow access:"; however, when you put in your credentials and click "Allow access", you are not actually logged into Linkedin.

My code was working fine on last week. Anyone else seeing this?


回答1:


Looks like you have oath2_access_token there instead of oauth_access_token ? Not sure if this is a hand-paste failure or the actual issue.

curl "https://api.linkedin.com/v1/people/~?format=json&oath2_access_token=############"



回答2:


Try this it work for me

get('https://api.linkedin.com/v1/people/~?oauth2_access_token=*******&format=json');

Hope that help some one




回答3:


This seems to be caused by triggering a security watchdog, i.e. after an invalid request or after requesting several access tokens without using them linkedin seems to stop validating tokens and responds 401 instead.




回答4:


in fact you need to add the two following header : Authorization : Bearear #ACCESS TOKEN# x-li-src : msdk regards



来源:https://stackoverflow.com/questions/32126255/unable-to-access-linkedin-profile-with-valid-oauth2-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!