Skip to content
/ ghjwt Public

Simple CLI tool for quickly generating GitHub Apps authn/authz JWTs

Notifications You must be signed in to change notification settings

mtodd/ghjwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

ghjwt

Simple CLI tool to quickly generate GitHub Apps authn/authz JWTs.

This is used to authenticate requests against the GitHub Apps endpoints: https://developer.github.com/v3/apps/

Learn about how to authenticate for these endpoints, and how to use the JWT generated by this tool, here: https://developer.github.com/apps/building-github-apps/authentication-options-for-github-apps/#authenticating-as-a-github-app

Installation

go get -u github.com/mtodd/ghjwt

Usage

To generate a valid JWT authentication token, given your GitHub Apps ID is 1234 and the private key PEM file generated from your GitHub Apps' settings can be found at path/to/private/key.pem:

ghjwt -iss 1234 -pem path/to/private/key.pem

This defaults to generating a valid token that expires 10 minutes from now. Use the -dur option to specify how long the JWT should be valid for, or set -exp with the specific unixtime expiration time for the key.

Example

jwt=$(ghjwt -iss 1234 -pem path/to/private/key/pem)
curl -i -H "Authorization: Bearer $jwt" -H "Accept: application/vnd.github.machine-man-preview+json" https://api.github.com/app

License

Copyright 2018 Matt Todd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Simple CLI tool for quickly generating GitHub Apps authn/authz JWTs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages