领英OAuth 2.0重定向URL

11
我正在尝试使用LinkedIn Omniauth 2 gem登录用户。我尝试了几种不同的重定向方式,阅读了几篇文章,但仍然无法正常工作。 我正在尝试在本地测试此功能。 Rails 4应用程序。 所使用的gem包括: omniauth omniauth-linkedin-oath2 在框中放置重定向URL的几次尝试包括:

https://www.linkedin.com/uas/oauth2/authorization?client_id=759dczzx23nyic&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Flinkedin%2Fcallback&response_type=code&scope=r_basicprofile+r_emailaddress&state=8da572e31a8e66e6b1de54acddd14937d976ed06d7ed3217&client_id=*

  • = API Key that needs to stay private

    http://localhost:3000
    
    http://localhost:3000/
    
    http://www.localhost:3000
    
    https://localhost:3000
    
    https://localhost:3000/
    
    https://www.localhost:3000
    

我把这两篇文章都看了一遍,但仍然无法尝试找到正确的重定向方法。

https://developer.linkedin.com/forum/register-your-oauth-2-redirect-urls

https://developer.linkedin.com/forum/oauth-20-redirect-url-faq-invalid-redirecturi-error

任何帮助我需要更改的内容都将是极好的。
3个回答

8

它们需要完全匹配您发送的内容:

http://localhost:3000/auth/linkedin/callback


嗨,这里有一个快速问题,@Eugenio Pace,公共IP地址能否用作LinkedIn OAuth重定向URI? - Hina Khuman
非常可能(也很容易测试)。OAuth2授权服务器的一个重要方面是所有通信都是从以下两者之一发起的: (1)用户的浏览器,(2)您的应用程序(OAuth2术语中的“客户端”) 因此,如果您使用自己的*/etc/hosts*文件和IP地址,实际上并不重要。只要您的浏览器或运行您的应用程序的代码可以访问LinkedIN(例如),您就没问题。 LinkedIN 永远不会与您的应用程序连接。 - Eugenio Pace

2

0

我遇到了类似的问题,并且在使用Auth0时不断收到“无效的redirect_uri。该值必须与API密钥注册的URL匹配。”的错误提示。

我将下面的URL添加到LinkedIn允许的回调列表中,然后它就正常工作了。

https://"Insert your Client Domain Name from Auth0"/login/callback

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接