sirkris / Reddit.NET

A Reddit API library for .NET Standard with OAuth support. Written in C#.
MIT License
509 stars 78 forks source link

redirect_uri invalid error with AuthTokenRetriever #178

Open tedead opened 1 year ago

tedead commented 1 year ago

Hi, I am following the instructions in the https://www.youtube.com/watch?v=xlWhLyVgN2s&ab_channel=KrisCraig video paying close attention to the redirect URI but I am getting a invalid redirect error response. I've tried using both 127.0.0.1 and localhost but still the same error.

I've also verified app id.

Any ideas what the issue may be?

sirkris commented 1 year ago

What is the exact URI you're specifying, and is it the same as what you have in your profile settings? If that second question has you scratching your head, then that's probably where the problem is. The redirect_uri you specify in the request has to EXACTLY match what you have it set to for that app in your Reddit profile, otherwise it'll throw that error.

JRAlexander commented 1 year ago

I ran into the same issue. I had to put http://127.0.0.1:8080/Reddit.NET/oauthRedirect in the profile. Also, make sure you copy all chars for your AppId...

cn-ml commented 1 year ago

In this line the default redirecturl property is initialized here.

The bug appears provided redirect url gets ignored in some functions including the AuthURL function:

until these two are replaced with the RedirectURL property the only workaround is to set the redirect URL in reddit settings (as @JRAlexander said).

As @sirkris commented here: the url has to be an exact match and the fix is very easy in the lib.

sirkris commented 1 year ago

@cn-ml Wow nice catch! At first, those values were just going to be hard-coded, but then I later changed it to be user-configurable. I could've sworn I'd updated all the references but apparently not.

On a side note, you should be aware that I've temporarily suspended support for this project due to a stupid new restriction Reddit imposed that is preventing me from developing new test apps. Basically, they've instituted a LIFETIME limit of just 3 apps per person. It used to be unlimited. As a result, I can't create any new test apps without either reusing another app's credentials (which I consider a deal-breaker for obvious security reasons) or deleting all but two of my apps. Since one is reserved for the library's test suite and another for the bundled Example project, this basically means I can't write any apps of my own without reusing Reddit.NET's test credentials.

I've submitted a request/complaint to Reddit. The support agent said they forwarded my request/feedback and now I'm just waiting for something to happen. I told them changing the limit to 3 per year instead of 3 for life would resolve my concerns and noted that it's been years since the last time I created a new app for Reddit. But apparently even that's too much?

Reddit has been making some really bizarre decisions regarding its API lately. But this one takes the cake. Plus it's kinda insulting. I mean, it's not like I'm getting paid for this and they're acting like no legitimate developer would ever need more than 3 sets of oAuth credentials.

For now, I am blocked on creating new test apps because I can't create any new app IDs, thanks to this recent change. Support will resume just as soon as Reddit fixes this and unblocks me.

So if you're wondering why nothing is happening right now, that's why. :/

cn-ml commented 12 months ago

Yeah, that was a small oversight there. Happened to me sometimes, too :)

About Reddit: you probably shouldn't bother waiting for replies. Most popular reddit devs have been abandoned and their apps left behind by the reddit admin team. Thanks for notifying me about the situation of this library, this makes me reconsider working on my current side project, unless this situation is fixed on reddits side.

Thanks for your effort 👍

sirkris commented 12 months ago

Yeah I haven't given up yet. I'll give them some time and then start pushing harder if I never hear back. I mean, unless they're outright declaring their intention to kill the API altogether at some point (which is my main concern at this point tbh), there's really no excuse for not having the limit reset after 1 year. They're literally saying they don't want us each to create more than 3 Reddit apps in our lifetime. I mean, come on.

Even if Reddit completely dogs me on this, I'll still probably wind up putting out one more release since I was already about to anyway. But for now I'm just watching and waiting.

IMakeTheSites commented 2 months ago

I was able to get the application approved, as I can see on my application page, but the redirect takes me to a page that doesn't exist, so I can't get the token. 127.0.0.1 returns no data, it says. Is this library function enough to complete this, or should I have another application running locally on that port in order to receive the token?