Linkedin OAuth2授权码错误 [英] Linkedin OAuth2 authorization code error

查看:288
本文介绍了Linkedin OAuth2授权码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 在linkedin中添加了我自己的应用程序。
  2. >
  3. 生成授权网址: https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=XXX&范围= r_basicprofile%20r_fullprofile%20r_emailaddress& state = DCEEFWF454Us5dffef424& redirect_uri = http:// localhost:9090 / springmvc / token.htm

  4. 介绍linkedin的登录名/密码新的弹出窗口。
  5. 在redirect_uri之前取回成功的请求,并获取授权代码code

  6. 生成accessToken URL
  7. li>
  8. 通过以下方式进行发布: https://www.linkedin.com/uas/ oauth2 / accessToken?grant_type = authorization_code& code = YYY& redirect_uri = http:// localhost:9090 / SpringMVC / token.htm& client_id = XXX& client_secret = ZZZ 获取响应中的下一个错误:{error_description:缺少必需的参数,包含一个无效的参数值,参数不止一次。 :无法检索访问令牌:appId或重定向URI与授权码或授权码过期不匹配,error:invalid_request}



我已验证的网址参数是正确的:
- code是在步骤4中接收到的令牌。


  • redirect_uri与第2步和第4步中的网址相同。我在我的APP上的OAuth 2.0重定向网址部分添加了此网址。

  • client_id和client_secret是我APP上的客户端API和秘密API。
  • 第一次和第二次请求之间的时间小于20秒。


解决方案您的 redirect_uri 参数必须是URL编码的,所以在6. do:

  https:// www。 linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=YYY&redirect_uri=http%3A%2F%2Flocalhost%3A9090%2FSpringMVC%2Ftoken.htm&client_id=XXX&client_secret=ZZZ 

,它不需要作为POST发送,而是作为GET发送。


I´m trying to connect via Linkedin Auth2 from a java web application:

  1. Added my own app in linkedin.
  2. Generate the authorization URL: https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=XXX&scope=r_basicprofile%20r_fullprofile%20r_emailaddress&state=DCEEFWF454Us5dffef424&redirect_uri=http://localhost:9090/springmvc/token.htm
  3. Introduce my login/password for linkedin in the new popup.
  4. Get back successful the request on the redirect_uri previus, and take the authorization code "code"
  5. Generate the accessToken URL
  6. Make a POST with: https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=YYY&redirect_uri=http://localhost:9090/SpringMVC/token.htm&client_id=XXX&client_secret=ZZZ
  7. Get next error in response: {"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired","error":"invalid_request"}

I´ve verified url parameters are correct: - "code" is the token receive on step 4.

  • "redirect_uri" is the same URL on step 2 and 4. I added this URL on section "OAuth 2.0 redirect URL" on my APP.

  • "client_id" and "client_secret" are the "Client API" and "Secret API" on my APP.

  • Time between first and second request is less than 20 seconds.

解决方案

The value of your redirect_uri parameter must be URL-encoded, so at 6. do:

 https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=YYY&redirect_uri=http%3A%2F%2Flocalhost%3A9090%2FSpringMVC%2Ftoken.htm&client_id=XXX&client_secret=ZZZ

and it need not be sent as a POST but as a GET.

这篇关于Linkedin OAuth2授权码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆