cyberark / conjur-api-python

Python client for the CyberArk Conjur API
Apache License 2.0
8 stars 3 forks source link

client.login returns await #49

Open wlwwu opened 5 months ago

wlwwu commented 5 months ago

Summary

with all the credentials provided, the client is returnning something error

Steps to Reproduce

from conjur_api.providers.authn_authentication_strategy import AuthnAuthenticationStrategy from conjur_api.providers.simple_credentials_provider import SimpleCredentialsProvider from conjur_api.models import SslVerificationMode,ConjurConnectionInfo,CredentialsData from conjur_api.client import Client from dotenv import load_dotenv, find_dotenv

import os

ENV_FILE = find_dotenv() if ENV_FILE: load_dotenv(ENV_FILE)

conjur_url = os.getenv("CONJUR_URL") account = os.getenv("ACCOUNT") username = os.getenv("CONJUR_LOGIN_ID") api_key = os.getenv("API_KEY") ssl_verification_mode = SslVerificationMode.TRUST_STORE

connection_info = ConjurConnectionInfo(conjur_url=conjur_url,account=account,cert_file=None)

credentials = CredentialsData(username=username, api_key=api_key, machine=conjur_url) credentials_provider = SimpleCredentialsProvider() credentials_provider.save(credentials) del credentials

authn_provider = AuthnAuthenticationStrategy(credentials_provider)

client = Client(connection_info, authn_strategy=authn_provider, ssl_verification_mode=ssl_verification_mode)

client.login()

Expected Results

it should return the login info, not the error info

Actual Results

ubuntu@host:/data/dev/conjur_api$ python3.10 auth.py /data/dev/conjur_api/auth.py:36: RuntimeWarning: coroutine 'Client.login' was never awaited client.login() RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Reproducible

Version/Tag number

What version of the product are you running? Any version info that you can share is helpful. For example, you might give the version from Docker logs, the Docker tag, a specific download URL, the output of the /info route, etc.

Environment setup

Additional Information

Add any other context about the problem here.

wlwwu commented 5 months ago

Traceback (most recent call last): File "/data/dev/conjur_api/auth.py", line 39, in asyncio.run(login()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/data/dev/conjur_api/auth.py", line 37, in login await client.login() File "/home/ubuntu/.local/lib/python3.10/site-packages/conjur_api/client.py", line 92, in login return await self._api.login() File "/home/ubuntu/.local/lib/python3.10/site-packages/conjur_api/http/api.py", line 100, in login return await self.authn_strategy.login( File "/home/ubuntu/.local/lib/python3.10/site-packages/conjur_api/providers/authn_authentication_strategy.py", line 47, in login raise MissingRequiredParameterException("password is required for login") conjur_api.errors.errors.MissingRequiredParameterException: password is required for login