Skip to content

Commit

Permalink
fix: added 'github_pat_' tokens as supported token types
Browse files Browse the repository at this point in the history
  • Loading branch information
ArshiaBP committed Nov 16, 2024
1 parent c4341b5 commit 6d519ca
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ClientAccessTokenCredential struct {
func (c *ClientAccessTokenCredential) GetClient(ctx context.Context) (*github.Client, error) {
var client *github.Client
// Authentication with GitHub access token
if strings.HasPrefix(c.Token, "ghp_") {
if strings.HasPrefix(c.Token, "ghp_") || strings.HasPrefix(c.Token, "github_pat_") {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: c.Token},
)
Expand Down Expand Up @@ -141,8 +141,8 @@ func checkCredentials(config Config) error {
return fmt.Errorf("'token' or 'app_id', 'installation_id' and 'private_key' must be set in the connection configuration")
}
// Return error for unsupported token by prefix
if config.Token != "" && !strings.HasPrefix(config.Token, "ghs_") && !strings.HasPrefix(config.Token, "ghp_") && !strings.HasPrefix(config.Token, "gho_") {
return fmt.Errorf("wrong token format. tokens should start with ghs_ or ghp_ or gho_")
if config.Token != "" && !strings.HasPrefix(config.Token, "ghs_") && !strings.HasPrefix(config.Token, "ghp_") && !strings.HasPrefix(config.Token, "gho_") && strings.HasPrefix(config.Token, "github_pat_") {
return fmt.Errorf("wrong token format. tokens should start with ghs_ or ghp_ or gho_ or github_pat_")
}
return nil
}
Expand Down

0 comments on commit 6d519ca

Please sign in to comment.