You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. .. python-keycloak documentation master file, created by
  2. sphinx-quickstart on Tue Aug 15 11:02:59 2017.
  3. You can adapt this file completely to your liking, but it should at least
  4. contain the root `toctree` directive.
  5. .. toctree::
  6. :maxdepth: 2
  7. :caption: Contents:
  8. Indices and tables
  9. ==================
  10. * :ref:`genindex`
  11. * :ref:`modindex`
  12. * :ref:`search`
  13. .. image:: https://travis-ci.org/marcospereirampj/python-keycloak.svg?branch=master
  14. :target: https://travis-ci.org/marcospereirampj/python-keycloak
  15. .. image:: https://readthedocs.org/projects/python-keycloak/badge/?version=latest
  16. :target: http://python-keycloak.readthedocs.io/en/latest/?badge=latest
  17. Welcome to python-keycloak's documentation!
  18. ===========================================
  19. **python-keycloak** is a Python package providing access to the Keycloak API.
  20. Installation
  21. ==================
  22. Via Pypi Package::
  23. $ pip install python-keycloak
  24. Manually::
  25. $ python setup.py install
  26. Dependencies
  27. ==================
  28. python-keycloak depends on:
  29. * Python 3
  30. * `requests <http://docs.python-requests.org/en/master/>`_
  31. * `python-jose <http://python-jose.readthedocs.io/en/latest/>`_
  32. Tests Dependencies
  33. ------------------
  34. * unittest
  35. * `httmock <https://github.com/patrys/httmock>`_
  36. Bug reports
  37. ==================
  38. Please report bugs and feature requests at
  39. `https://github.com/marcospereirampj/python-keycloak/issues <https://github.com/marcospereirampj/python-keycloak/issues>`_
  40. Documentation
  41. ==================
  42. The documentation for python-keycloak is available on `readthedocs <http://python-keycloak.readthedocs.io>`_.
  43. Contributors
  44. ==================
  45. * `Agriness Team <http://www.agriness.com/pt/>`_
  46. Usage
  47. =====
  48. Main methods::
  49. from keycloak import Keycloak
  50. # Configure client
  51. keycloak = Keycloak(server_url="http://localhost:8080/auth/",
  52. client_id="example_client",
  53. realm_name="example_realm",
  54. client_secret_key="secret")
  55. # Get WellKnow
  56. config_well_know = keycloak.well_know()
  57. # Get Token
  58. token = keycloak.token("user", "password")
  59. # Get Userinfo
  60. userinfo = keycloak.userinfo(token['access_token'])
  61. # Logout
  62. keycloak.logout(token['refresh_token'])
  63. # Get Certs
  64. certs = keycloak.certs()
  65. # Get RPT (Entitlement)
  66. token = keycloak.token("user", "password")
  67. rpt = keycloak.entitlement(token['access_token'], "resource_id")
  68. # Instropect RPT
  69. token_rpt_info = keycloak.instropect(keycloak.instropect(token['access_token'], rpt=rpt['rpt'],
  70. token_type_hint="requesting_party_token"))
  71. # Instropect Token
  72. token_info = keycloak.instropect(token['access_token']))
  73. # Decode Token
  74. KEYCLOAK_PUBLIC_KEY = "secret"
  75. options = {"verify_signature": True, "verify_aud": True, "exp": True}
  76. token_info = keycloak.decode_token(token['access_token'], key=KEYCLOAK_PUBLIC_KEY, options=options)