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

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

问题描述

我正在尝试从 Java Web 应用程序通过 Linkedin Auth2 进行连接:

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

  1. 在linkedin中添加了我自己的应用.
  2. 生成授权网址: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. 在新弹出窗口中介绍我的linkedin登录名/密码.
  4. 在redirect_uri previus上取回成功请求,并取授权码code"
  5. 生成访问令牌 URL
  6. 使用以下内容发布 POST: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. 在响应中获取下一个错误:{"error_description":"缺少必需的参数,包括无效的参数值,参数不止一次.:无法检索访问令牌:appId 或重定向 uri 与授权代码不匹配或授权代码已过期","error":"invalid_request"}

我已经验证了 url 参数是正确的:- code"是第 4 步收到的令牌.

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

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

  • "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"和client_secret"是我APP上的Client API"和Secret API".

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

第一次和第二次请求之间的时间少于 20 秒.

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

推荐答案

redirect_uri 参数的值必须是 URL 编码的,所以在 6. do:

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

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

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

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

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