Golang API + approle login

895 views
Skip to first unread message

Amit Saha

unread,
Jul 23, 2017, 12:29:59 AM7/23/17
to Vault
Hey all,

Am I right in thinking that the golang API doesn't have a way to login via an approle? (https://github.com/hashicorp/vault/tree/master/api). The Python client has t FWIW https://github.com/ianunruh/hvac/blob/27617419a62dff1d9419cf55d7adb5c4b9d39f36/hvac/v1/__init__.py#L924

Best Wishes,
Amit.



Chris Hoffman

unread,
Jul 23, 2017, 9:34:26 AM7/23/17
to vault...@googlegroups.com
Although there is no explicit method, you can easily accomplish this with the general write methods.

    data := map[string]interface{}{
        "role_id":   roleID,
        "secret_id": secretID,
    }
    resp, err := client.Logical().Write("auth/approle/login", data)
    if err != nil {
        return err
    }

    if resp.Auth == nil {
        return fmt.Errorf("no auth info returned")
    }


Chris

--
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/c82fa81b-9f95-4d90-a475-5a5fbbf2edac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Amit Saha

unread,
Jul 29, 2017, 1:23:01 AM7/29/17
to Vault


On Sunday, July 23, 2017 at 11:34:26 PM UTC+10, Chris Hoffman wrote:
Although there is no explicit method, you can easily accomplish this with the general write methods.

    data := map[string]interface{}{
        "role_id":   roleID,
        "secret_id": secretID,
    }
    resp, err := client.Logical().Write("auth/approle/login", data)
    if err != nil {
        return err
    }

    if resp.Auth == nil {
        return fmt.Errorf("no auth info returned")
    }



Thank you. That worked.
Reply all
Reply to author
Forward
0 new messages