Boilerplate OAuth flow for shell scripts integrating with the Github v3 API
It is surprisingly easy to add OAuth to your Github-integrated application. Hopefully this boilerplate, though basic, is enough to get you started!
- Clone this repository to your computer
- Navigate to the resulting directory
- Open ./auth.sh in vim -
vim ./auth.sh
- Replace "XXXX..." with your OAuth application's CLIENT_ID and CLIENT_SECRET on lines 15 and 16
- Exit vim and execute
source ./auth.sh
- Execute
login
to initiate basic Github OAuth flow (NOTE: a .session.sh file is temporarily created) - Execute
logout
to logout of Github OAuth (NOTE: your Github token is stored in .token.sh) - Review code and comments on auth.sh and read Github's v3 API documentation
- Extend code if needed and use in your application
- Participate: leave a comment, open issues, send improvements, and give a star if you like what you see 😊
This boilerplate does not yet support 2-Factor Authentication, but this is in the works. See the following link if you would like to extend the code yourself, and feel free to send a pull-request if you do!
Implementing 2-Factor Authentication: https://developer.github.com/v3/auth/#working-with-two-factor-authentication