-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support GitHub Apps Installation authentication #69
Merged
Merged
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
cc3c430
Initial commit of github apps poc
kfcampbell d810a54
Demo of GitHub Apps auth working in go-sdk
kfcampbell 5dbbe40
Remove unnecessary auth configuration functions
kfcampbell c7a0760
Docs comments cleanup
kfcampbell 89748f0
Differentiate App and token auth examples
kfcampbell ec62501
Merge branch 'main' into apps-poc
kfcampbell ac183c0
Switch to using fork of ghinstallation
kfcampbell 6e4307a
Bump to latest ghinstallation fork version
kfcampbell fce8ecc
Allow authorizing with clientID
kfcampbell 17193b7
Refactor naming to default to clientID for App auth
kfcampbell 916a677
Bump kfcampbell/ghinstallation version
kfcampbell e405d53
Rename WithAuthorizationToken to WithTokenAuthentication
kfcampbell 7d369b2
Add README note about different types of App auth
kfcampbell 1155962
Simplify token initialization client
kfcampbell 0b56dbf
Another ghinstallation version bump
kfcampbell b15e87d
Use env vars for App auth example
kfcampbell a604459
Test coverage for Apps auth
kfcampbell 9007016
Merge branch 'main' into apps-poc
kfcampbell 1a4d9fc
Update pkg/client.go
kfcampbell 9bf71d2
Fix build error from code suggestion
kfcampbell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
abs "github.com/microsoft/kiota-abstractions-go" | ||
"github.com/octokit/go-sdk/pkg" | ||
"github.com/octokit/go-sdk/pkg/github/installation" | ||
) | ||
|
||
func main() { | ||
client, err := pkg.NewApiClient( | ||
pkg.WithUserAgent("my-user-agent"), | ||
pkg.WithRequestTimeout(5*time.Second), | ||
pkg.WithBaseUrl("https://api.github.com"), | ||
// pkg.WithAuthorizationToken(os.Getenv("GITHUB_TOKEN")), | ||
pkg.WithGitHubAppAuthentication("/home/kfcampbell/github/dev/go-sdk/kfcampbell-terraform-provider.2024-04-30.private-key.pem", 131977, 20570954), | ||
) | ||
|
||
// equally valid: | ||
//client, err := pkg.NewApiClient() | ||
if err != nil { | ||
log.Fatalf("error creating client: %v", err) | ||
} | ||
|
||
queryParams := &installation.RepositoriesRequestBuilderGetQueryParameters{} | ||
requestConfig := &abs.RequestConfiguration[installation.RepositoriesRequestBuilderGetQueryParameters]{ | ||
QueryParameters: queryParams, | ||
} | ||
repos, err := client.Installation().Repositories().Get(context.Background(), requestConfig) | ||
if err != nil { | ||
log.Fatalf("error getting repositories: %v", err) | ||
} | ||
|
||
if len(repos.GetRepositories()) > 0 { | ||
log.Printf("Repositories:\n") | ||
for _, repo := range repos.GetRepositories() { | ||
log.Printf("%v\n", *repo.GetFullName()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The fluent syntax here makes me want to consider how we might be able to propagate that to other SDKs - it feels really good.