snoowrap
snoowrap copied to clipboard
uploadStylesheetImage : Unhandled rejection StatusCodeError: 403 - {"message":"Forbidden","error":403}
r.getSubreddit('Subname').uploadStylesheetImage({ name:'commentbox', file: './commentbox.png' });
immediately throws Unhandled rejection StatusCodeError: 403 - {"message":"Forbidden","error":403}
Any ideas ?
answering my own question - doing the oauth with username/password worked - image uploaded flawlessly
My guess is that your OAuth token did not have sufficient scope to modify the subreddit stylesheet, or you weren't a mod on that subreddit.
hmm i just tried again by adding scope: 'modconfig' to my new snoowrap but no dice. ( and created a new token with the modconfig scope)
I' m trying to run the updateStylesheet and uploadStylesheetImage routine but both are giving me the 403 error when using the non - username/password connector.
Any ideas ? ( I am a mod - even a creator - of the subreddit )
hmm i just tried again by adding scope: 'modconfig' to my new snoowrap but no dice. ( and created a new token with the modconfig scope)
I'm not sure if this is what you meant, but modifying the scope property on a snoowrap instance won't have any effect -- the only thing that matters is the token that you create the snoowrap instance with.
Are you creating a snoowrap instance with a token with modconfig scope? Are you able to access other endpoints that require modconfig (such as getSettings) with an access token?
I created token with modconfig scope.
updateStylesheet did not work either
- Do other endpoints (such as
getTop()work as expected? - Can you add
r.config({debug: true})and show me what gets printed?
ok. done
You ll see 3 errors:
- one for submitLink call
- one for updateStylesheet call
- one for getTop
I obviously edited out some stuff for privacy. (thanks a lot for taking the time)
expires_in: 3600,
refresh_token: 'my token is here,
scope: 'modconfig' }
Username-MacBook-Pro:snoowrap-master myusername$ node index.js
[debug] Received a 403 status code from a post request sent to https://oauth.reddit.com/api/submit?raw_json=1. ratelimitRemaining: null
Unhandled rejection StatusCodeError: 403 - {"message":"Forbidden","error":403}
at new StatusCodeError (/Users/myusername/node_modules/request-promise/lib/errors.js:32:15)
at /Users/myusername/node_modules/request-promise/lib/rp.js:70:37
at tryCatcher (/Users/myusername/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/myusername/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/myusername/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/myusername/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/Users/myusername/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/myusername/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/myusername/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
[debug] Received a 403 status code from a get request sent to https://oauth.reddit.com/r/Mysubredditname/top?raw_json=1&count=9999&t=all. ratelimitRemaining: null
Unhandled rejection StatusCodeError: 403 - {"message":"Forbidden","error":403}
at new StatusCodeError (/Users/myusername/node_modules/request-promise/lib/errors.js:32:15)
at /Users/myusername/node_modules/request-promise/lib/rp.js:70:37
at tryCatcher (/Users/myusername/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/myusername/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/myusername/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/myusername/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/Users/myusername/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/myusername/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/myusername/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
[debug] Received a 200 status code from a post request sent to https://oauth.reddit.com/r/Mysubredditname/api/subreddit_stylesheet?raw_json=1. ratelimitRemaining: 599
Username-MacBook-Pro:snoowrap-master myusername$