A User Token Generator/refresher for Server Interactive Scripts.
This is similar to how the Google NodeJS API's examples work.
- You start a script, it shows a URL to open.
- You Google oAuth
- A code is displayed
- User/You copy and paste the code back into the interactive script
- Away we go
When you (re)start the example_task.js script again, it will validate the token, refresh if it can and if needed prompt for a fresh set of keys/tokens. seeder.js is a more simple request code for token exchanger and likely the thing you need.
- Open
config_sample.jsonin a text editor - Visit Twitch Dev Console
- Visit Applications
- Manage your Application, or create one if you don't have one
- Copy the Client ID into the
""ofclient_id - Hit New Secret then Ok
- Copy the new Client Secret into the
""ofclient_secret - Add or change the
OAuth Redirect URLsto include one forhttps://barrycarlyon.github.io/twitch_misc/examples/auth_code_no_server/as Twitch now support multiples, or copy the HTML/JS of that example to your own server and use that URL - Save your modified file as
config.json
You can change the port in config if you want but remember to change it in the Redirect URL's as well, and update the configs redirect_uri
There are two examples.
example_task.jsis a interactive script for doing a task after getting auth and handling refresh, could be interative/shell based chnanel points or title managmentseeder.jswill do a code for token exchange and store the access and refresh into redis. Something else will use and manage the refresh of that token, this could be a chat bot where you didn't want to expose port 80 or 443
In a console/terminal, run these commands:
npm installnode example_task.js- Follow the instructions
This Example script requires the use of a WebPage to capture and Display the ?code to be copy and pasted to the script.
An example of this is provided elsewhere in this repo