我正在使用 'omniauth-linkedin-oauth2'。
当我用Linkedin登录时,遇到了以下错误:
无效的redirect_uri。此值必须与API密钥注册的URL匹配。
这是我的设置:
我正在使用 'omniauth-linkedin-oauth2'。
当我用Linkedin登录时,遇到了以下错误:
无效的redirect_uri。此值必须与API密钥注册的URL匹配。
这是我的设置:
我回到了领英开发者网站 (https://www.linkedin.com/secure/developer) 再次检查了我的设置。 API密钥、秘密密钥和OAuth 2.0重定向URL都匹配。
在网上搜索一些线索,但是找不到任何一个。
疯狂的问题:
然后我看到Owin在重定向URI中添加了一些额外的字符串“signin-linkedin”。当我解码URL时,我看到了这个http://localhost:54307/signin-linkedin 。我将此URL放置在LinkedIn开发人员网站中的OAuth 2.0重定向URL字段中。
https://www.linkedin.com/uas/oauth2/authorization?scope=r_basicprofile+r_emailaddress&state=XXXXXX&redirect_uri=http://example.com.au/sa/complete/linkedin-oauth2/&response_type=code&client_id=YYYYYYY
http://example.com/sa/complete/linkedin-oauth2/
对于此,我添加了OAuth 2.0授权重定向URL的网址: http://localhost:1729/signin-linkedin 其中,http://localhost:1729 代表基本URL,signin-linkedin代表在基本URL之后添加的字符串。
另一个解决方案是验证您一直在使用的client_id
,因为随着重定向URI列表的每次更新,客户端ID也会更新。
http://localhost:8000/oauth/complete/linkedin-oauth2
http://localhost:8000/oauth/complete/linkedin-oauth2/
http://localhost:3000/auth/linkedin/callback
,这是OmniAuth策略的工作方式。接下来,您应该将站点打开为http://localhost:3000
并尝试进行身份验证。 - Ilya Bodrov-Krukowski