Skip to main content

FusionAuth Python Client semver 2.0.0 compliant

Intro

If you're integrating FusionAuth with a Python 3 application, this library will speed up your development time. Please also make sure to check our SDK Usage Suggestions page.

For additional information and documentation on FusionAuth refer to https://fusionauth.io.

Install

To install the FusionAuth Python Client package run:

pip install fusionauth-client

This library can be found on PyPI at https://pypi.org/project/fusionauth-client/.

Examples

Set Up

First, you have to make sure you have a running FusionAuth instance. If you don't have one already, the easiest way to install FusionAuth is via Docker, but there are other ways. By default, it'll be running on localhost:9011.

Then, you have to create an API Key in the admin UI to allow calling API endpoints.

You are now ready to use this library.

Create the Client

Include the package in your code by using the following statement.

from fusionauth.fusionauth_client import FusionAuthClient

Now you're ready to begin making requests to FusionAuth. You will need to supply an API key you created in FusionAuth, the following example assumes an API key of 6b87a398-39f2-4692-927b-13188a81a9a3.

client = FusionAuthClient('6b87a398-39f2-4692-927b-13188a81a9a3', 'http://localhost:9011')

Error Handling

After every request is made, you need to check for any errors and handle them. To avoid cluttering things up, we'll omit the error handling in the next examples, but you should do something like the following.

Create an Application

To create an Application, use the create_application() method.

data = {
    'application': {
        'name': 'ChangeBank'
    }
}

result = client.create_application(data)

# Handle errors as shown in the beginning of the Examples section

# Otherwise parse the successful response
print(result.success_response)

Check the API docs for this endpoint

Adding Roles to an Existing Application

To add roles to an Application, use create_application_role().

data = {
    'role': {
        'name': 'customer',
        'description': 'Default role for regular customers',
        'isDefault': 1
    }
}

result = client.create_application_role(
    application_id='5a89377e-a250-4b15-b766-377ecc9b9fc9',
    request=data
)

# Handle errors as shown in the beginning of the Examples section

# Otherwise parse the successful response
print(result.success_response)

Check the API docs for this endpoint

Retrieve Application Details

To fetch details about an Application, use retrieve_application().

result = client.retrieve_application(
    application_id='5a89377e-a250-4b15-b766-377ecc9b9fc9'
)
print(result.success_response)

Check the API docs for this endpoint

Delete an Application

To delete an Application, use delete_application().

client.delete_application(
    application_id='5a89377e-a250-4b15-b766-377ecc9b9fc9'
)

Check the API docs for this endpoint

Lock a User

To prevent a User from logging in, use deactivate_user().

client.deactivate_user(
    user_id='231b982c-9304-4642-9bac-492d6917f5aa'
)

Check the API docs for this endpoint

Registering a User

To register a User in an Application, use register().

The code below also adds a customer role and a custom appBackgroundColor property to the User Registration.

result = client.register(
    user_id='231b982c-9304-4642-9bac-492d6917f5aa',
    request={
        'registration': {
            'applicationId': '5a89377e-a250-4b15-b766-377ecc9b9fc9',
            'roles': [
                'customer'
            ],
            'data': {
                'appBackgroundColor': '#096324'
            }
        }
    }
)
print(result.success_response)

Check the API docs for this endpoint

Questions and support

If you find any bugs in this library, please open an issue. Note that changes to the FusionAuthClient class have to be done on the FusionAuth Client Builder repository, which is responsible for generating that file.

But if you have a question or support issue, we'd love to hear from you.

If you have a paid plan with support included, please open a ticket in your account portal. Learn more about paid plan here.

Otherwise, please post your question in the community forum.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/fusionauth-python-client.

Note: if you want to change the FusionAuthClient class, you have to do it on the FusionAuth Client Builder repository, which is responsible for generating all client libraries we support.

License

This code is available as open source under the terms of the Apache v2.0 License.

Upgrade Policy

This library is built automatically to keep track of the FusionAuth API, and may also receive updates with bug fixes, security patches, tests, code samples, or documentation changes.

These releases may also update dependencies, language engines, and operating systems, as we'll follow the deprecation and sunsetting policies of the underlying technologies that it uses.

This means that after a dependency (e.g. language, framework, or operating system) is deprecated by its maintainer, this library will also be deprecated by us, and will eventually be updated to use a newer version.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fusionauth_client-1.69.0.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fusionauth_client-1.69.0-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file fusionauth_client-1.69.0.tar.gz.

File metadata

  • Download URL: fusionauth_client-1.69.0.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.6

File hashes

Hashes for fusionauth_client-1.69.0.tar.gz
Algorithm Hash digest
SHA256 11b66bda20c83b6d7161a0926e04fac334facac4ea008fd8d003aaffcabf4202
MD5 c7fa8f3f891705fbf113455c2d93b251
BLAKE2b-256 df1061c5c53a35f2c28b1618223101b3cd7280d206bcd369a424fa4c9b2f22cf

See more details on using hashes here.

File details

Details for the file fusionauth_client-1.69.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fusionauth_client-1.69.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09052da83374b726db0b23ef8db5ee540d5d0a60645e0c75ee9b69ff4597bcae
MD5 00f49ce79c9b2b206e94b0edf4d8351f
BLAKE2b-256 a5645f27f1ed094679548e552a398810cbf1d914bd60e20d69d8643e25cba498

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.69.0 This release

2 files

1.68.0

2 files

1.67.0

2 files

1.65.0

2 files

1.64.0

2 files

1.63.0

2 files

1.62.0

2 files

1.61.0

2 files

1.60.0

2 files

1.59.0

2 files

1.58.2

2 files

1.58.1

2 files

1.58.0

2 files

1.57.0

2 files

1.56.0

2 files

1.55.0

2 files

1.53.0

2 files

1.52.0

2 files

1.51.0

2 files

1.50.0

2 files

1.49.1

2 files

1.48.0

2 files

1.47.0

2 files

1.46.0

2 files

1.45.0

2 files

1.44.0

2 files

1.43.0

2 files

1.42.0

2 files

1.41.0

2 files

1.36.0

2 files

1.34.0

2 files

1.33.0

2 files

1.32.1

2 files

1.32.0

2 files

1.31.0

2 files

1.30.2

2 files

1.30.0

2 files

1.29.1

2 files

1.29.0

2 files

1.28.1

2 files

1.28.0

2 files

1.27.2

2 files

1.27.1

2 files

1.27.0

2 files

1.26.0

2 files

1.25.0

2 files

1.24.0

2 files

1.23.0

2 files

1.22.2

2 files

1.22.1

2 files

1.22.0

2 files

1.21.0

2 files

1.20.1

2 files

1.20.0

2 files

1.19.8

2 files

1.19.0

2 files

1.18.8

2 files

1.18.0

2 files

1.17.0

2 files

1.16.0

2 files

1.15.4

2 files

1.15.3

2 files

1.15.2

2 files

1.14.0

2 files

1.13.1

2 files

1.13.0

2 files

1.12.1

2 files

1.12.0

2 files

1.11.0

2 files

1.10.1

2 files

1.9.0

2 files

1.7.4

2 files

1.7.2

2 files

1.7.0

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

3 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.1.0

2 files

1.0.17

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page