Sunday 12 November 2017

How to check if a Reddit Access Token is valid with NodeJS?

I am making an NPM module for the Reddit API. client.authenticate('my access token'); How am I able to test if my access token is a valid Access Token? Is there something I can fetch with their token that tells me?This is how my code is set up currently:class Client { constructor(options = {}) { this.clientId = options.clientId; this.clientSecret = options.clientSecret; } authorize(token) { return new Promise((resolve, reject) => { // if access token is valid, resolve with the token // if access token is invalid reject(new Error('You provided an invalid token.')); }); } } Furthermore, I'd like methods I make to only be available if the user has authenticated (they have that one line of code and token is correct).

Submitted November 12, 2017 at 11:54PM by Rusty_TV

No comments:

Post a Comment