From cbaeade0f672e77f7e65107f14fd4df741f1127d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Tue, 17 Dec 2024 10:10:47 +0100 Subject: [PATCH] chore: detect if the token is JWT or Token type --- utils/context.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/context.go b/utils/context.go index df53a866..ac94f392 100644 --- a/utils/context.go +++ b/utils/context.go @@ -2,6 +2,7 @@ package utils import ( context2 "context" + "encoding/base64" "encoding/json" "errors" "github.com/qovery/qovery-client-go" @@ -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 }