@@ -78,11 +78,12 @@ type ServiceAccountKeyResponse struct {
7878}
7979
8080type ServiceAccountKeyCredentials struct {
81- Aud string `json:"aud"`
82- Iss string `json:"iss"`
83- Kid string `json:"kid"`
84- PrivateKey * string `json:"privateKey,omitempty"`
85- Sub uuid.UUID `json:"sub"`
81+ Aud string `json:"aud"`
82+ Iss string `json:"iss"`
83+ Kid string `json:"kid"`
84+ PrivateKey * string `json:"privateKey,omitempty"`
85+ Sub uuid.UUID `json:"sub"`
86+ TokenEndpoint string `json:"tokenEndpoint"`
8687}
8788
8889// GetConfig returns the flow configuration
@@ -117,13 +118,26 @@ func (c *KeyFlow) GetToken() TokenResponseBody {
117118 return * c .token
118119}
119120
121+ // getCredentialsTokenEndpoint returns the token endpoint from credentials or a default fallback
122+ func (cfg * KeyFlowConfig ) getCredentialsTokenEndpoint () string {
123+ if cfg .ServiceAccountKey == nil || cfg .ServiceAccountKey .Credentials == nil {
124+ return tokenAPI
125+ }
126+
127+ if cfg .ServiceAccountKey .Credentials .TokenEndpoint == "" {
128+ return tokenAPI
129+ }
130+
131+ return cfg .ServiceAccountKey .Credentials .TokenEndpoint
132+ }
133+
120134func (c * KeyFlow ) Init (cfg * KeyFlowConfig ) error {
121135 // No concurrency at this point, so no mutex check needed
122136 c .token = & TokenResponseBody {}
123137 c .config = cfg
124138
125139 if c .config .TokenUrl == "" {
126- c .config .TokenUrl = tokenAPI
140+ c .config .TokenUrl = c . config . getCredentialsTokenEndpoint ()
127141 }
128142
129143 c .tokenExpirationLeeway = defaultTokenExpirationLeeway
0 commit comments