Skip to content

Commit

Permalink
fix: machine identity auth
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Jan 6, 2025
1 parent 99df234 commit 4a9c2cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions infisical_sdk/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class SingleSecretResponse(BaseModel):

@classmethod
def from_dict(cls, data: Dict) -> 'ListSecretsResponse':
"""Create model from dictionary with camelCase keys, handling nested objects"""
return cls(
secret=BaseSecret.from_dict(data['secret']),
)
Expand All @@ -120,5 +119,5 @@ class MachineIdentityLoginResponse(BaseModel):
"""Response model for machine identity login API"""
accessToken: str
expiresIn: int
accessTokenMaxTtl: int
accessTokenMaxTTL: int
tokenType: str
10 changes: 6 additions & 4 deletions infisical_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def set_token(self, token: str):
"""
Set the access token for future requests.
"""
self._api_config.access_token = token
self.api.set_token(token)

def get_token(self):
"""
Expand All @@ -57,8 +57,8 @@ def login(self, client_id: str, client_secret: str) -> MachineIdentityLoginRespo
"""

requestBody = {
"client_id": client_id,
"client_secret": client_secret
"clientId": client_id,
"clientSecret": client_secret
}

result = self.client.api.post(
Expand All @@ -67,6 +67,8 @@ def login(self, client_id: str, client_secret: str) -> MachineIdentityLoginRespo
model=MachineIdentityLoginResponse
)

self.client.set_token(result.data.accessToken)

return result.data


Expand Down Expand Up @@ -120,7 +122,7 @@ def login(self, identity_id: str) -> MachineIdentityLoginResponse:
model=MachineIdentityLoginResponse
)

self.client.set_token(result.data.access_token)
self.client.set_token(result.data.accessToken)

return result.data

Expand Down

0 comments on commit 4a9c2cd

Please sign in to comment.