[英]Invalid redirect_uri parameter for Reddit API
I'm trying to implement oAuth with Reddit using Devise & the omniauth-reddit gem. 我正在尝试使用Devise和omniauth-reddit gem通过Reddit实现oAuth。
It seems to be passing the local url & api key fine. 它似乎正在传递本地url和api键。
https://ssl.reddit.com/api/v1/authorize?response_type=account&client_id=API_KEY&redirect_uri=http%3A%2F%2F127.0.0.1%3A3000%2Fusers%2Fauth%2Freddit%2Fcallback&scope=identity
However the response I get is: 但是我得到的响应是:
forbidden (reddit.com)
you are not allowed to do that
— invalid redirect_uri parameter.
I've tried setting the redirect_uri to 127.0.0.1:3000 as well as hosted url(heroku), but to no avail. 我尝试将redirect_uri设置为127.0.0.1:3000以及托管的url(heroku),但无济于事。
So now I don't understand if I'm still just giving them the wrong URL or passing a parameter that shouldn't be there. 所以现在我不明白我是否仍然只是给他们错误的URL或传递了不应该存在的参数。
Thanks for any help! 谢谢你的帮助!
Ok. 好。 So I just figured out a
irritating fun little quirk with the Reddit API: 因此,我刚刚使用Reddit API找出了一个
令人讨厌的有趣小怪癖:
Turns out, it also returns the — invalid redirect_uri parameter
error if there's an invalid client ID
! 事实证明,如果存在无效的
client ID
,它还会返回— invalid redirect_uri parameter
错误! Clearly, I thought the client_id
was the same thing as the secret
显然,我认为
client_id
与secret
是一回事
NOPE 不
Instead, it's the easy-to-miss ID that's right below your application name. 相反,它是您应用程序名称正下方的易于识别的ID。 Once you use the proper ID, everything works .
使用正确的ID后,一切正常。 .
。 .
。
OAuth servers (almost always) require that you register the callback address with them. OAuth服务器(几乎总是)要求您向它们注册回调地址。 Have you done that?
你做完了吗? They check that what you send in the
redirect_uri
matches what you entered. 他们检查您在
redirect_uri
中发送的内容是否与您输入的内容匹配。 In Reddit: 在Reddit中:
Just tested it. 刚刚测试。 You have to enter the exact callback URL:
您必须输入确切的回调URL:
http://127.0.0.1:3000/users/auth/reddit/callback
If you miss one segment, it will report that error. 如果您错过了一个细分,它将报告该错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.