snoowrap
snoowrap copied to clipboard
Cannot auth
Hey.
const otherRequester = new snoowrap({
userAgent: 'put your user-agent string here',
clientId: 'put your client id here',
clientSecret: 'put your client secret here',
username: 'put your username here',
password: 'put your password here'
});
throws "Unhandled rejection TypeError: Cannot read property 'split' of undefined" when populated correctly. I've checked the object and the info being put in, it should be working.
const r = new snoowrap({
userAgent: 'put your user-agent string here',
clientId: 'put your client id here',
clientSecret: 'put your client secret here',
refreshToken: 'put your refresh token here'
});
After fetching my refresh token according to documentation, and populating it here: Unhandled rejection StatusCodeError: 400 - {"message":"Bad Request","error":400}
Is there something wrong with this repo or my account?
All of this data is reaching the snoowrap object during instantiation just fine, but after creating that object using methods just throws errors as if it never authenticated.
I'm having trouble authenticating too. I'm using a script type app, and following the docs to the letter:
const reddit = new snoowrap({
userAgent: 'script:myapp:v1 (by /u/my_username)',
clientId: process.env.REDDIT_CLIENT_ID,
clientSecret: process.env.REDDIT_CLIENT_SECRET,
username: process.env.REDDIT_USERNAME,
password: process.env.REDDIT_PASSWORD,
});
Even though the reddit
object has all values populated as I expected, using any API methods results in:
Error: "Invalid grant" error returned from reddit. (You might have incorrect credentials.)
While I'm working on a new app, I've copy/pasted code I've used in the past with success, so this seems like a new issue with Reddit or with authentication code, or both.
Would appreciate any help or suggestions!
Edit: I've solved my issue. I appear to have been getting rejected due to an incorrectly formatted User Agent. Once I followed the pattern they suggest in the docs: <platform>:<app ID>:<version string> (by /u/<reddit username>)
, my requests started working.
Great to hear david.
@DylanAlloy sorry for late response. Can you add debug=true
into the config and tell me more? By the info you give me I can't debug more. The second code snippet of
const r = new snoowrap({
userAgent: 'put your user-agent string here',
clientId: 'put your client id here',
clientSecret: 'put your client secret here',
refreshToken: 'put your refresh token here'
});
is most likely user-error as it returns Bad Request
. The first code snippet with 'split' on undefined however is something I want to look closer at as it's not a helpful error to the user
@davidtom I had that same issue and just had to change up my app name a bit to get it working. Thanks.