File: index.rst

package info (click to toggle)
python-hvac 2.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,800 kB
  • sloc: python: 29,360; makefile: 42; sh: 14
file content (53 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Auth Methods
============

.. toctree::
   :maxdepth: 2

   approle
   aws
   azure
   gcp
   github
   jwt-oidc
   kubernetes
   ldap
   legacymfa
   okta
   token
   userpass

Authenticate to different auth backends
---------------------------------------

.. code:: python


    # App ID
    client.auth_app_id('MY_APP_ID', 'MY_USER_ID')

    # GitHub
    client.auth.github.login('MY_GITHUB_TOKEN')

    # TLS
    client = Client(cert=('path/to/cert.pem', 'path/to/key.pem'))
    client.auth.cert.login()

    # Non-default mount point (available on all auth types)
    client.auth.userpass.login('MY_USERNAME', 'MY_PASSWORD', mount_point='CUSTOM_MOUNT_POINT')

    # Authenticating without changing to new token (available on all auth types)
    result = client.auth.github.login('MY_GITHUB_TOKEN', use_token=False)
    print(result['auth']['client_token']) # => u'NEW_TOKEN'

    # Custom or unsupported auth type
    params = {
        'username': 'MY_USERNAME',
        'password': 'MY_PASSWORD',
        'custom_param': 'MY_CUSTOM_PARAM',
    }

    result = client.login('/v1/auth/CUSTOM_AUTH/login', json=params)

    # Logout
    client.logout()