Skip to content

Commit

Permalink
Add StaticCredentials parser
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvoleg committed Nov 28, 2024
1 parent 217ad43 commit 99553fa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ydb_dbapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,23 @@ def prepare_credentials(

if isinstance(credentials, dict):
credentials = credentials or {}

username = credentials.get("username")
if username:
password = credentials.get("password")
return ydb.StaticCredentials.from_user_password(
username,
password,
)

token = credentials.get("token")
if token:
return ydb.AccessTokenCredentials(token)

service_account_json = credentials.get("service_account_json")
if service_account_json:
return ydb.iam.ServiceAccountCredentials.from_content(
json.dumps(service_account_json)
json.dumps(service_account_json),
)

return ydb.AnonymousCredentials()

0 comments on commit 99553fa

Please sign in to comment.