Skip to content

Python3 using HVAC with “approle” authentication to pull secret from Hashivault #748

Answered by Tylerlhess
CTinMich asked this question in Q&A
Discussion options

You must be logged in to vote

First off I recommend doing a

CLIENT.is_authenticated()

just to make sure that your token is working.
Second all the approle stuff I have seen you have the role-id and use that to request the secret-id (if you don't have it and have secret_bound_cidr on the role) then authenticate with role-id, secret-id

Mostly from the docs....

import hvac
client = hvac.Client()

resp = client.auth.approle.generate_secret_id(
role_name='some-role',
cidr_list=['127.0.0.1/32'],
)

secret_id = resp["body"]["secret_id"]

client.auth.approle.login(
role_id='<some_role_id>',
secret_id='<some_secret_id>',
)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@CTinMich
Comment options

@CTinMich
Comment options

Answer selected by briantist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants