The following is a proper example of how to use curl to login to reddit:
curl -duser=USERNAME -dpasswd=PASSWORD -dapi_type=json https://ssl.reddit.com/api/login
By passing api_type=json you get meaningful json output rather than reddit-specific jquery based output.
{"json": {"errors": [],
"data": {"modhash": "<REMOVED>",
"cookie": "<REMOVED>"}
}
}
Note that reddit also properly uses the set-cookie header so that a proper http client / library will take advantage of the session for subsequent requests.
Your example did not work because you were not properly sending the form parameters. The example that you thought might have worked, in-fact did not. You were receiving a rate-limit response for failing to login too many times.
Answer from bboe on Stack OverflowWe created application and generated oauth_token but we can't find the way how to use it to login into API to receive more information about our subredit posts (we need information if the post is approved or not for us to embed it on website). We also can't find it in the reddit api documentation. Any response is appreciate, thank you in advance.
Videos
Hello, everyone.
I want to use the Reddit API just to experiment a bit with its data. I want to build an app for customer discovery and market research, and right now I haven't written a single line of code. I only want to see what I can do with the API and then I might build something.
However, the registration form is asking me for OAuth Client ID, an About URL and Redirect URI. How am I supposed to have these when I haven't even started building anything yet? I'm a senior year undergrad CS student and at this point I'm only looking to experiment a bit.
Can people please guide me how I can register for the API?
If this is not the right place to ask this question, please, let me know where I can post it.
Thanks.
How do you authenticate?
The API docs live here: https://www.reddit.com/dev/api It includes no information on how to use your client id and secret to authenticate.
This Github page) describes the procedure, but it hasn't been updated in 4 years, and when I attempt it, the token request call pulls up an HTML web page vice a JSON response.
There's a Python wrapper called PRAW, but it seems to be a bit messy, and it's also not clear if it's current. In general, Libs tend to be overkill for these sorts of API.
Is the Reddit API current and supported? How do you authenticate? Thank you.
Hello,
I use a website and I got the REST APIs that the website UI calls to display various details from the network tab. I do not want to use the website's UI as there are so many details which I am not interested in. Instead, I would like to build a CLI tool which fetches just the details I need.
The problem I face now is this.
The website that I use uses "Sign in with Google" option. When I click on that button, it takes me to the google sign in page and once I login, it returns a code (authorization code, I think - it has a slash as the second character, always) which is then passed to the website for authentication as a callback, I suppose. On receipt, the website returns a Bearer token. With this Bearer token, the UI calls the backend to retrieve the JSON's.
Now, I need this to be done fully without using any UI and it's associated redirection to google sign in, as I plan to develop a only a CLI tool. I would like to pass my email id and password to the tool and expect to get the code from Google's Oauth which I can then presumably use to get the token from the website.
Any help would be very helpful.
Thanks
I've been trying to implement a "Login with Reddit" button on a website - similar to Login with Google / Facebook / Twitter / GitHub / whatever.
I've got the OAuth thing working. First time a user tries it, they get the expected Reddit permission page for indefinite access to identity then they get sent to my callback and the world is a happy place until they log out.
However, next time they attempt to login using Reddit, they are once again presented with the authorization page, even though their Apps page on Reddit clearly lists the app as already authorized.
It should be immediately redirecting to the callback, but it isn't. If they Approve again, then it redirects.
I've been digging through google, asking other devs, and scanning this sub. I guess two years ago this was a "we're aware of it" thing? https://www.reddit.com/r/redditdev/comments/2nk8xq/why_must_users_of_my_website_reallow_access_to_my/
This isn't a matter of re-presenting a known token, as I do not have their token when they click on the login button. I've only implemented Google and FB so far but both of them work flawlessly after initial approval. I'd love to get Reddit working.
Is there anything I might be missing or is this simply not something I can do for my users?
Hey folks, this is baffling me - how do I create a new app/get API credentials?
When I go to /pref/apps I just get a "You are already logged in and will be redirected"
But when I get redirected I end up on the same screen.
Any insights? :-)
Thanks!
To use a python script to post on behalf of a reddit account, I need this to set it up:
reddit = praw.Reddit(client_id='YOUR_CLIENT_ID',client_secret='YOUR_CLIENT_SECRET',user_agent='YOUR_USER_AGENT',username='YOUR_REDDIT_USERNAME',password='YOUR_REDDIT_PASSWORD')
However, for the username and password, how can I make it so that the user can just Sign in with Reddit and authorize my web app? It's like using Login with Google via Firebase, but I'm not familiar with the reddit configuration process. Obviously the users will not send me their username and passwords. And some users login with google to reddit, so they don't have these credentials.
I want to use command line tool curl to change the Sidebar of my channel. is it possible use username and password only just like github api?
for example:
curl https://reddit.com/r/SpaceVim/api/site_admin -X POST -u wsdjeg:********* -d "{\"description\" : \"sss\"}"Although it's technically possible, this authentication method is deprecated. You should be using OAuth2 for this kind of thing. Most languages have an API wrapper that supports this endpoint as well.
WTF! why down voted? user can not post feature request in this channel?
Hi,
i'm running out of attempts... just got this "you are doing that too much. try again in 27 minutes." so I thought I would come here and ask.
This is the request I'm sending
URL:
http://www.reddit.com/api/login/
Headers:
User-Agent: "Reddit test app"
POST DATA:
user=USERNAME&passwd=PASSWORD&api_type=json
Putting the parameters in the URL instead... strangely works! I would like to avoid this though as it may not be safe to pass the password in the URL.
e.g. http://www.reddit.com/api/login/?user=USERNAME&passwd=PASSWORD&api_type=json
Another question... how do I access /api/v1/me/ ?
Tried passing modhash as a GET/POST parameter, and also by passing "uh" as a Header. None of them work.
Any ideas what I'm doing wrong? Thanks! :)
I'm pulling my hair out, hoping someone can help. I've spent an embarrassing amount of time banging my head against the wall.
I have a simple script I'm working on, it authenticates and gets a bearer token. I am able to get json of the comments endpoint for example no problem.
If I try to go to the inbox, with bearer token, it redirects me to a login page and of course doesn't work. I could hack the login and password in to the request I guess, but isn't that what the token is for?
Any help at all is much appreciated.
EDIT: more information
Just to add https://oauth.reddit.com/api/v1/me works and returns json with my user info
Note that it says here: https://github.com/reddit-archive/reddit/wiki/OAuth2
that
"API requests with a bearer token should be made to https://oauth.reddit.com, NOT www.reddit.com."
Near as I can tell this is either bullshit or way out of date. I don't seem to be allowed to do ANYTHING at oauth except get th token and ask about myself.