Simple Rust example of oauth with twitch
- Register an app at dev.twitch.tv
- Put your client-id into a file named,
client-id
- Put your client-secret into a file named,
client-secret
cargo run
this program in the same directory as your client-id and client-secret- The program will print a URL, paste that into your browser. Note: You may need to use a private browsing window to avoid a CSRF error. You will also need to open port 8080 to receive the redirect from twitch.
- The program will make one more HTTP POST, if that is successful it will write your new oauth token to a file named
oauth-token
.
This is just a toy sketch and not a fully fleshed out instance of how you should do this in a real application. For example, this throws away the renew code. Also it has the scope hard coded to channel:read:redemptions
.