Skip to content

Commit

Permalink
chore: detect if the token is JWT or Token type
Browse files Browse the repository at this point in the history
  • Loading branch information
erebe committed Dec 17, 2024
1 parent 1347362 commit cbaeade
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
context2 "context"
"encoding/base64"
"encoding/json"
"errors"
"github.com/qovery/qovery-client-go"
Expand Down Expand Up @@ -305,6 +306,10 @@ func GetAccessToken() (AccessTokenType, AccessToken, error) {
apiToken = os.Getenv("Q_CLI_ACCESS_TOKEN")
}
if apiToken != "" {
_, err := base64.StdEncoding.DecodeString(strings.Split(apiToken, ".")[0])
if err == nil {
return "Bearer", AccessToken(apiToken), nil
}
return "Token", AccessToken(apiToken), nil
}

Expand Down

0 comments on commit cbaeade

Please sign in to comment.