fastai / ghapi

A delightful and complete interface to GitHub's amazing API
https://ghapi.fast.ai/
Apache License 2.0
527 stars 57 forks source link

add support for endpoints that require jwt_token #87

Closed ffalor closed 2 years ago

ffalor commented 2 years ago

Adds jwt_token attribute to GhApi to allow users to call app endpoints that require a jwt token instead of a pat/access_key

closes #85

This should allow you to authenticate to the following endpoints:

And probably more, these were just the ones I quickly tested.

For example:

jwt = create_jwt(app_id, private_key)

app_api = GhApi(jwt_token=jwt)

print("List Installations")
installations = app_api.apps.list_installations()
print(installations)

print("Get Access Token")
id = installations[0]['id']
print(app_api.apps.create_installation_access_token(id))
List Installations

[- id: 1111
- account: 
  - login: ffalor
  - id: 1
  - node_id: MDQ6VXNlcjM1MTQ0MTQx
  #etc...]

Get Access Token
- token: ghs_324324234234
- expires_at: 2021-08-21T11:40:36Z
- permissions: 
  - administration: read
  - contents: read
  - issues: write
  - metadata: read
- repository_selection: all

Not 100% what all I can update since from my understanding this project is auto generated. I did not see any tests to update. Please let me know what would need to change in order to add the ability to provide a jwt_token.

review-notebook-app[bot] commented 2 years ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB