Skip to main content

Get a key

Obtain an access key

Use the vault to retrieve public key material and any associated metadata.

Get the current key version

If no key version is specified, the current key version will be retrieved.


import os

import pangea.exceptions as pe
from pangea.config import PangeaConfig
from pangea.services import Vault


def get_key(key_id):
token = os.getenv("PANGEA_VAULT_TOKEN")
domain = os.getenv("PANGEA_DOMAIN")
config = PangeaConfig(domain=domain)
vault = Vault(token, config=config)

try:
# if no version is specified curent_version is returned
response = vault.get(key_id)
except pe.PangeaAPIException as e:
print(f"Vault Request Error: {e.response.summary}")
for err in e.errors:
print(f"\t{err.detail} \n")

return response.result.current_version.public_key

Get a specific key version

It may be useful to get a specific key version to decrypt data or verify a signature signed with an earlier key version.


import os

import pangea.exceptions as pe
from pangea.config import PangeaConfig
from pangea.services import Vault


def get_key_version(key_id, version):
token = os.getenv("PANGEA_VAULT_TOKEN")
domain = os.getenv("PANGEA_DOMAIN")
config = PangeaConfig(domain=domain)
vault = Vault(token, config=config)

try:
# specify a version
response = vault.get(key_id, version)
except pe.PangeaAPIException as e:
print(f"Vault Request Error: {e.response.summary}")
for err in e.errors:
print(f"\t{err.detail} \n")

# specify a version index, as more than one version can be returned
return response.result.versions[0].public_key

Was this article helpful?

Contact us