Groups
Groups
Sign in
Groups
Groups
Vault
Conversations
About
Send feedback
Help
Reading only the secret value using HTTP APIs
916 views
Skip to first unread message
Hemant Gupta
unread,
Jan 20, 2016, 3:49:50 PM
1/20/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Vault
I am using the below weblink as a reference to access the secret from Vault.
https://www.vaultproject.io/intro/getting-started/apis.html
I am able to successfully read the secret using the below curl command:
$ curl \
-H "X-Vault-Token:$VAULT_TOKEN" \
http://127.0.0.1:8200/v1/secret/foo
However, as an output I just need the secret value and not the whole json.
In other words, I just need
baz
as a string from the below output:
{
"lease_id": "secret/foo/cc529d06-36c8-be27-31f5-2390e1f6e2ae",
"renewable": false,
"lease_duration": 2592000,
"data": {
"bar": "baz"
},
"auth": null
}
Jeff Mitchell
unread,
Jan 20, 2016, 3:53:13 PM
1/20/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vault...@googlegroups.com
Hi Hemant,
I recommend piping the output to 'jq', which can do all sorts of
transformation and filtering -- I think something like "jq 'data.bar'"
should work.
Alternately, if the Vault CLI is available, you can use the -field
option to 'vault read'.
--Jeff
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
>
https://www.hashicorp.com/community-guidelines.html
. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues:
https://github.com/hashicorp/vault/issues
> IRC: #vault-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vault" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
vault-tool+...@googlegroups.com
.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/vault-tool/b694d11f-8057-45fe-92b5-6bc29b467715%40googlegroups.com
.
> For more options, visit
https://groups.google.com/d/optout
.
Hemant Gupta
unread,
Jan 21, 2016, 12:51:06 AM
1/21/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Vault
Thanks Jeff for your response.
I am able to get the value by piping as below:
python -c 'import sys, json; print json.load(sys.stdin)["data"]["value"]'
Reply all
Reply to author
Forward
0 new messages