snoowrap icon indicating copy to clipboard operation
snoowrap copied to clipboard

uploadStylesheetImage : Unhandled rejection StatusCodeError: 403 - {"message":"Forbidden","error":403}

Open belgianwolfie opened this issue 7 years ago • 7 comments

r.getSubreddit('Subname').uploadStylesheetImage({ name:'commentbox', file: './commentbox.png' });

immediately throws Unhandled rejection StatusCodeError: 403 - {"message":"Forbidden","error":403}

Any ideas ?

belgianwolfie avatar Feb 07 '18 15:02 belgianwolfie

answering my own question - doing the oauth with username/password worked - image uploaded flawlessly

belgianwolfie avatar Feb 07 '18 22:02 belgianwolfie

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.

not-an-aardvark avatar Feb 07 '18 23:02 not-an-aardvark

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 )

belgianwolfie avatar Feb 07 '18 23:02 belgianwolfie

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?

not-an-aardvark avatar Feb 08 '18 20:02 not-an-aardvark

I created token with modconfig scope.

updateStylesheet did not work either

belgianwolfie avatar Feb 08 '18 20:02 belgianwolfie

  • Do other endpoints (such as getTop() work as expected?
  • Can you add r.config({debug: true}) and show me what gets printed?

not-an-aardvark avatar Feb 08 '18 20:02 not-an-aardvark

ok. done

You ll see 3 errors:

  1. one for submitLink call
  2. one for updateStylesheet call
  3. 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$

belgianwolfie avatar Feb 08 '18 20:02 belgianwolfie