-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Organization PAT fields to InstallationPermissions struct #3243
Add Organization PAT fields to InstallationPermissions struct #3243
Conversation
In the article "[Organization APIs for fine-grained PATs management](https://github.blog/changelog/2023-03-24-organization-apis-for-fine-grained-pats-management/)", following new 2 permissions are added to GitHub Apps - organization_personal_access_tokens - organization_personal_access_token_requests These permissions are used for getting and updating GitHub Organization's Fine-grained PAT's lists, requests, revokes. [APIs of Organization permissions for "Personal access tokens"](https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps?apiVersion=2022-11-28#organization-permissions-for-personal-access-tokens) [APIs of Organization permissions for "Personal access token requests"](https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps?apiVersion=2022-11-28#organization-permissions-for-personal-access-token-requests) We can test these permissions following test codes, and successfully I got installation token from GitHub. ```go package main import ( "context" "log" "net/http" "github.com/bradleyfalzon/ghinstallation/v2" "github.com/google/go-github/v64/github" ) func main() { ctx := context.Background() tr := http.DefaultTransport itr, err := ghinstallation.NewAppsTransportKeyFromFile(tr, <your-app-id>, <your-private-key-path>) if err != nil { log.Fatal(err) } client := github.NewClient(&http.Client{Transport: itr}) token, _, err := client.Apps.CreateInstallationToken( ctx, <your-installation-id>, &github.InstallationTokenOptions{ Permissions: &github.InstallationPermissions{ OrganizationPersonalAccessTokens: github.String("read"), OrganizationPersonalAccessTokenRequests: github.String("read"), }, }) if err != nil { log.Fatal(err) } log.Println(token.GetToken()) } ``` Signed-off-by: Hi120ki <[email protected]>
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Thank you, @hi120ki ! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3243 +/- ##
==========================================
- Coverage 97.72% 92.95% -4.78%
==========================================
Files 153 171 +18
Lines 13390 11646 -1744
==========================================
- Hits 13085 10825 -2260
- Misses 215 727 +512
- Partials 90 94 +4 ☔ View full report in Codecov by Sentry. |
…, and passed the test and lint I checked following commands are passed. ``` $ script/fmt.sh $ script/test.sh $ script/lint.sh ``` Signed-off-by: Hi120ki <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @hi120ki !
LGTM.
Merging.
In the article "Organization APIs for fine-grained PATs management", following new 2 permissions are added to GitHub Apps
These permissions are used for getting and updating GitHub Organization's Fine-grained PAT's lists, requests, revokes.
APIs of Organization permissions for "Personal access tokens"
APIs of Organization permissions for "Personal access token requests"
We can test these permissions following test codes, and successfully I got installation token from GitHub.