简体   繁体   English

如何使用python从credstash获取凭据?

[英]How to get credentials from credstash using python?

In node, I used to do it this way 在节点中,我曾经这样做

const Credstash = require('nodecredstash');

    const credstash = new Credstash({
        table: <table_name>,
        kmsKey: <kms_key>,
      });

      return credstash.getSecret({
        name: <secret_name>,
        context: { access: <secret_name> },
      })

I tried same using python package credstash as per following code 我按照以下代码使用python包credstash尝试了相同的操作

import credstash as cd
secret=cd.getSecret(name=<secret_name>,table=<table_name>,context={ 'access': <secrest_name>},kms={ 'key': <kms_key>})
print('GOT', secret)

But giving error 但是给错误

AttributeError: 'dict' object has no attribute 'decrypt'

Figured it out. 弄清楚了。 Missed a kms client. 错过了kms客户。

import boto3
import credstash as cd
from json import loads

kms = boto3.client('kms')

secret=cd.getSecret(
name=<secret_name>,
table=<table_name>,
context={ 'access': <secret_name>},
kms=kms)
print('GOT', loads(secret))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python中使用credstash - Using credstash in Python 使用Python获取Google OAuth凭据 - Get Google OAuth credentials using Python 无法使用python从Google表格的Google API获取凭据; 公司代理背后 - Can't get credentials from Google API for Google Sheets using python; behind company proxy 如何使用python使用默认凭据登录路由器 - How to login into router with default credentials using python 如何从 Python 中的.secrets 文件中调用凭据 - How to Call the Credentials from .secrets File in Python 使用Datadog的Python API,是否可以获取自己的凭据,如果可以,怎么办? - Using Datadog's Python API, is it possible to get your own credentials, and if so, how? 如何使用来自 Chrome 的相同凭据在 python 中发出 API 请求? - How can I make an API request in python using the same credentials from Chrome? 如何使用 Python 和托管标识/SAS 凭据从 VM 访问 Azure 存储帐户 - How to access Azure storage account from VM using Python and managed identity / SAS credentials 如何在Google AppEngine Python37中获取凭据 - How to get credentials in Google AppEngine Python37 如何使用Python添加Windows凭据? - How can I add Windows Credentials using Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM