Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris McIntosh authored Aug 8, 2023
1 parent 07a72fb commit 7422dc8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions generate-jwt-key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@ See [the docs](https://docs.github.com/en/developers/apps/authenticating-with-gi
```
npm install
node generate-jwt-key.js --private-key /path/to/key
curl -i -H "Authorization: Bearer $(node generate-jwt-key.js --private-key /path/to/key)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app
curl -i -H "Authorization: Bearer $(node generate-jwt-key.js -i <app id> --private-key /path/to/key)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app
```

## Get Installation token flow
### Get Installations
```
curl -i -H "Authorization: Bearer $(node generate-jwt-key.js --private-key /path/to/key)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations
curl -i -H "Authorization: Bearer $(node generate-jwt-key.js -i <app id> --private-key /path/to/key)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations
```

### Get Token
```
curl -i -H "Authorization: Bearer $(node generate-jwt-key.js --private-key /path/to/key)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations/<installation id>/access_tokens
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $(node generate-jwt-key.js -i <app id> -p /path/to/key)" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/app/installations/<installation_id>/access_tokens \
-d '{"repository":"<repo-name>","permissions":{"contents":"read"}}'
```
*Note:* Permissions JSON object must match [these properties](https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app-permissions-object) and your App must be granted the scopes you requested


### Use Token like a PAT
```
curl -i -H "Authorization: Bearer <token>" -H "Accept: application/vnd.github.v3+json" https://api.github.com/user
curl -i -H "Authorization: Bearer <installation_token>" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OWNER/REPO
```

0 comments on commit 7422dc8

Please sign in to comment.