Receiving an invalid grant error despite all credentials being correct. Does anyone know the routes I should post to and what headers and data I should include?
The code I tried is here:
exports.redditPost = async (subreddit) => {
const redditBot = new snoowrap({
userAgent: `${process.env.REDDIT_USER_AGENT}`,
clientId: `${process.env.REDDIT_CLIENT_ID}`,
clientSecret: `${process.env.REDDIT_CLIENT_SECRET}`,
username: `${process.env.REDDIT_USERNAME}`,
password: `${process.env.REDDIT_PASSWORD}`
});
try{
await redditBot.getSubreddit(subreddit).submitLink({
title: 'Title of Post',
url: `https://example.com`,
})
} catch(err){
console.log(err)
}
}
Error: "Invalid grant" error returned from reddit. (You might have incorrect credentials.) at /Users/name/GitHub/project/Main/node_modules/snoowrap/dist/request_handler.js:280:15 at process.processImmediate (node:internal/timers:471:21) From previous event: at snoowrap.updateAccessToken (/Users/name/GitHub/project/Main/node_modules/snoowrap/dist/request_handler.js:275:8) at /Users/name/GitHub/project/Main/node_modules/snoowrap/dist/request_handler.js:83:18 at listOnTimeout (node:internal/timers:564:17) at process.processTimers (node:internal/timers:507:7)
I tried changing my credentials and finding the API routes but can't find the exact ones and what data to include. I want to try and post a link on a subreddit of my choice.