I have a community discord where I want to show my number of subscribers in real time without having to update it myself. I use node.js to edit the info in the server via discord.js. Now I have the problem that I can’t see my subscribers without an oauth token with scope channel:read:subscribers. I’ve been with this problem for over 2 weeks now and I try something different every day but I get stuck. Can someone help me on my way?
EDIT: I forgot to say, I’m trying this with a request from my server (node.js file running)?
I just saw your question on the bottom, so yea step 1 basicly… doing it on a server. The github page kinda helped but I’m not 100% sure. Testing it rn.
hey @BarryCarlyon, I got myself a “code” to use in the Access Token. First question, for how long will this code work? And second, in step 4 the docs says " However, you should build your applications in such a way that they are resilient to token authentication failures. In other words, an application capable of refreshing tokens should not need to know how long a token will live. Rather, it should be prepared to deal with the token becoming invalid at any time. " What do you recommend doing here? Should I check when a response is token expired ? or just set a timeout that runs when the time should be over for a new AT?
The call to generate a token returns the expires in time
You can also use the validate endpoint
To validate a token and get the remaining time on a token.
Depends what I’m using the token for.
For subscribers, like your use case, I always attempt to refresh the token before I fetch all subscribers, because I either fetch once per day, (so the token will always be dead), or my the time schedule I use I’ll do a validate first to check the token and refresh as needed to fit my time schedule