Infisical / sdk

Infisical cross-language SDK
https://infisical.com
Other
21 stars 3 forks source link

Can't retrieve secrets with Python SDK #24

Closed lincis closed 4 months ago

lincis commented 4 months ago

Running copy / past code from quick start:

if_client = InfisicalClient(ClientSettings(
    client_id = os.environ.get('INFISICAL_MACHINE_ID'),
    client_secret = os.environ.get('INFISICAL_TOKEN')
))
neo_host = if_client.getSecret(options = GetSecretOptions(
    project_id = 'Hunome',
    environment = 'dev',
    secret_name = 'HNM_NEO4J_HOST'
))

I run into the following error:

Exception                                 Traceback (most recent call last)
Cell In[29], line 6
      1 from infisical_client import InfisicalClient, ClientSettings, GetSecretOptions
      2 if_client = InfisicalClient(ClientSettings(
      3     client_id = os.environ.get('INFISICAL_MACHINE_ID'),
      4     client_secret = os.environ.get('INFISICAL_TOKEN')
      5 ))
----> 6 neo_host = if_client.getSecret(options = GetSecretOptions(
      7     project_id = 'Hunome',
      8     environment = 'dev',
      9     secret_name = 'HNM_NEO4J_HOST'
     10 ))

File ~/project_path/.venv/lib/python3.11/site-packages/infisical_client/infisical_client.py:42, in InfisicalClient.getSecret(self, options)
     41 def getSecret(self, options: GetSecretOptions) -> SecretElement:
---> 42     result = self._run_command(Command(get_secret=options))
     44     return ResponseForGetSecretResponse.from_dict(result).data.secret

File ~/project_path/.venv/lib/python3.11/site-packages/infisical_client/infisical_client.py:36, in InfisicalClient._run_command(self, command)
     33 response = json.loads(response_json)
     35 if response["success"] == False:
---> 36     raise Exception(response["errorMessage"])
     38 return response

Exception: [Bad request]: failed to find bot key

The auth (client id / secret) is fine, if I mess with that, HTTP 403 is reported. Project with the name provided as project_id (do not see any other ID for the project in web ui), environment and secret with the name exist. Was working like charm with the old SDK infisical==1.4.1.

SDK: infisical-python==2.1.6 @ Python-3.11.6 on Linux

DanielHougaard commented 4 months ago

Hi @lincis! It seems that you haven't disabled End-to-end encryption (E2EE), which is required.

You can find the option to disable E2EE in your project settings. Let me know if that doesn't work for you!

lincis commented 4 months ago

@DanielHougaard, disabled E2EE for the project, but the result is still the same.

lincis commented 4 months ago

Sorry wrong information, was probably some cached results, checked again this morning, now it is fine.