Skip to content

Commit 89f4cef

Browse files
authored
fix: Trim API token on read to avoid accidental line break issues (#269)
This should help when someone adds a line break at the end of the token accidentally
1 parent 810f995 commit 89f4cef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

auth/token.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ func NewTokenClient() *TokenClient {
7373
func (tc *TokenClient) GetToken() (Token, error) {
7474
tokenType := tc.GetTokenType()
7575
if tokenType != BearerToken {
76-
return Token{Type: tokenType, Value: os.Getenv(EnvVarCloudQueryAPIKey)}, nil
76+
tokenFromEnv := os.Getenv(EnvVarCloudQueryAPIKey)
77+
trimmedToken := strings.TrimSpace(tokenFromEnv)
78+
return Token{Type: tokenType, Value: trimmedToken}, nil
7779
}
7880

7981
// If the token is not expired, return it

0 commit comments

Comments
 (0)