MCPcopy Create free account
hub / github.com/github/gh-aw / ClassifyPAT

Function ClassifyPAT

pkg/stringutil/pat_validation.go:53–67  ·  view source on GitHub ↗

ClassifyPAT determines the type of a GitHub Personal Access Token based on its prefix. Token prefixes: - "github_pat_" = Fine-grained PAT (required for Copilot) - "ghp_" = Classic PAT (not supported for Copilot) - "gho_" = OAuth token (not a PAT at all) Parameters: - token: The token string to cla

(token string)

Source from the content-addressed store, hash-verified

51// Returns:
52// - PATType: The type of the token
53func ClassifyPAT(token string) PATType {
54 var patType PATType
55 switch {
56 case strings.HasPrefix(token, "github_pat_"):
57 patType = PATTypeFineGrained
58 case strings.HasPrefix(token, "ghp_"):
59 patType = PATTypeClassic
60 case strings.HasPrefix(token, "gho_"):
61 patType = PATTypeOAuth
62 default:
63 patType = PATTypeUnknown
64 }
65 patLog.Printf("Classified PAT type: %s", patType)
66 return patType
67}
68
69// ValidateCopilotPAT validates that a token is a valid fine-grained PAT for Copilot.
70// Returns an error if the token is not a fine-grained PAT with a descriptive error message.

Callers 4

TestClassifyPATFunction · 0.85
ValidateCopilotPATFunction · 0.85
GetPATTypeDescriptionFunction · 0.85

Calls 1

PrintfMethod · 0.45

Tested by 2

TestClassifyPATFunction · 0.68