Retrieve HCP API token
Endpoint: /oauth/token
Before you can interact with the HCP Vault Secrets API, you must request a OAuth token.
You must pass the HCP service principal key pair (client ID and secret ID) to authenticate with HCP.
HCP_CLIENT_ID
- set the value to your service principal client IDHCP_CLIENT_SECRET
- set the value to your service principal client secret
Example
This example stores the OAuth token in the HCP_API_TOKEN
variable. The HCP_CLIENT_ID
and HCP_CLIENT_SECRET
values are passed in as variables.
Retrieve HCP organization and project ID
Once you have the HCP OAuth token, you must also retrieve your HCP Vault Secrets application name, the organization ID, and the project ID.
If you have the HCP Vault Secrets command line interface (CLI) binary installed and configured,
you can retrieve the values by reading vlt config
.
API request
You can now make an API request using the HCP OAuth token.
Refer to the HCP Vault Secrets API documentation for a list of all available endpoints and parameters.
Examples
Get available applications
The HCP_API_TOKEN
,HCP_CLIENT_ID
, and HCP_CLIENT_SECRET
values are passed in as variables.
Example output:
Get available secrets
The HCP_API_TOKEN
,HCP_CLIENT_ID
, HCP_CLIENT_SECRET
, and APP_NAME
values are passed in as variables.
Example output: