├── .python-version ├── src ├── main │ └── python │ │ ├── __init__.py │ │ └── fusionauth │ │ ├── __init__.py │ │ └── rest_client.py ├── test │ ├── python │ │ ├── __init__.py │ │ └── fusionauth │ │ │ ├── __init__.py │ │ │ ├── rest_client_test.py │ │ │ └── fusionauth_client_test.py │ └── docker │ │ ├── poll-for-kickstart-finish.sh │ │ ├── docker-compose.yml │ │ └── kickstart │ │ └── kickstart.json └── examples │ └── python │ ├── login.py │ ├── create_user.py │ ├── retrieve_user_by_email.py │ ├── create_and_register_user.py │ └── bulk_import.py ├── .github ├── CODEOWNERS └── workflows │ ├── test.yaml │ └── deploy.yaml ├── .gitignore ├── fusionauth-python-client.iml ├── setup.py ├── README.md └── LICENSE /.python-version: -------------------------------------------------------------------------------- 1 | 3.12.6 2 | -------------------------------------------------------------------------------- /src/main/python/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | __import__('pkg_resources').declare_namespace(__name__) 3 | except ImportError: 4 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 5 | -------------------------------------------------------------------------------- /src/test/python/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | __import__('pkg_resources').declare_namespace(__name__) 3 | except ImportError: 4 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is a managed file. Manual changes will be overwritten. 2 | # https://github.com/FusionAuth/fusionauth-public-repos/ 3 | 4 | .github/ @fusionauth/owners @fusionauth/platform 5 | -------------------------------------------------------------------------------- /src/main/python/fusionauth/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | __import__('pkg_resources').declare_namespace(__name__) 3 | except ImportError: 4 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 5 | -------------------------------------------------------------------------------- /src/test/python/fusionauth/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | __import__('pkg_resources').declare_namespace(__name__) 3 | except ImportError: 4 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ### Python template 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # Distribution / packaging 9 | .Python 10 | build/ 11 | develop-eggs/ 12 | dist/ 13 | downloads/ 14 | eggs/ 15 | .eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | wheels/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | MANIFEST 26 | *.iws 27 | 28 | # Installer logs 29 | pip-log.txt 30 | pip-delete-this-directory.txt 31 | 32 | 33 | **/.DS_Store 34 | .savant/cache 35 | -------------------------------------------------------------------------------- /src/examples/python/login.py: -------------------------------------------------------------------------------- 1 | from fusionauth.fusionauth_client import FusionAuthClient 2 | 3 | client = FusionAuthClient('APIKEY', 'http://localhost:9011') 4 | 5 | application_id = '20ce6dac-b985-4c77-bb59-6369249f884b' 6 | 7 | # Authenticate a user 8 | response = client.login({ 9 | 'loginId': 'python@example.com', 10 | 'password': 'password', 11 | 'applicationId': application_id 12 | }) 13 | 14 | if response.success_response: 15 | user = response.success_response['user'] 16 | print(user['id']) 17 | else: 18 | print(response.error_response) 19 | -------------------------------------------------------------------------------- /src/examples/python/create_user.py: -------------------------------------------------------------------------------- 1 | from fusionauth.fusionauth_client import FusionAuthClient 2 | 3 | 4 | # You must supply your API key and URL here 5 | client = FusionAuthClient('api-key', 'http://localhost:9011') 6 | 7 | user_request = { 8 | 'sendSetPasswordEmail': False, 9 | 'skipVerification': True, 10 | 'user': { 11 | 'email': 'art@vandaleyindustries.com', 12 | 'password': 'password' 13 | } 14 | } 15 | 16 | client_response = client.create_user(user_request) 17 | 18 | if client_response.was_successful(): 19 | print(client_response.success_response) 20 | else: 21 | print(client_response.error_response) 22 | -------------------------------------------------------------------------------- /src/examples/python/retrieve_user_by_email.py: -------------------------------------------------------------------------------- 1 | from fusionauth.fusionauth_client import FusionAuthClient 2 | 3 | 4 | # You must supply your API key and URL here 5 | client = FusionAuthClient('api-key', 'http://localhost:9011') 6 | 7 | user_request = { 8 | 'sendSetPasswordEmail': False, 9 | 'skipVerification': True, 10 | 'user': { 11 | 'email': 'art@vandaleyindustries.com', 12 | 'password': 'password' 13 | } 14 | } 15 | 16 | client_response = client.create_user(user_request) 17 | if client_response.was_successful(): 18 | print(client_response.success_response) 19 | else: 20 | print(client_response.error_response) 21 | 22 | client_response = client.retrieve_user_by_email('art@vandaleyindustries.com') 23 | if client_response.was_successful(): 24 | print(client_response.success_response) 25 | else: 26 | print(client_response.error_response) 27 | -------------------------------------------------------------------------------- /fusionauth-python-client.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | with open("README.md", "r") as fh: 4 | long_description = fh.read() 5 | 6 | setup( 7 | name="fusionauth-client", 8 | version="1.62.0", 9 | author="FusionAuth", 10 | author_email="dev@fusionauth.io", 11 | description="A client library for FusionAuth", 12 | long_description=long_description, 13 | long_description_content_type="text/markdown", 14 | url="https://github.com/FusionAuth/fusionauth-python-client", 15 | packages=find_packages(where="src/main/python"), 16 | namespace_packages=["fusionauth"], 17 | package_dir={"": "src/main/python"}, 18 | classifiers=[ 19 | "Programming Language :: Python :: 3", 20 | "License :: OSI Approved :: Apache Software License", 21 | "Operating System :: OS Independent", 22 | "Topic :: Software Development :: Libraries", 23 | ], 24 | install_requires=[ 25 | "deprecated", 26 | "requests", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /src/test/docker/poll-for-kickstart-finish.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, FusionAuth, All Rights Reserved 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, 11 | # software distributed under the License is distributed on an 12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 13 | # either express or implied. See the License for the specific 14 | # language governing permissions and limitations under the License. 15 | # 16 | 17 | cd $(dirname "$0") 18 | 19 | isFusionAuthReady () { 20 | docker compose logs fusionauth 2>&1 | grep -Fq 'Completed [POST] request to [/api/user/registration/00000000-0000-0000-0000-000000000008]' 21 | } 22 | 23 | max_retries=20 24 | i=1 25 | while [ "$i" -le "$max_retries" ]; do 26 | echo -n "[$i/$max_retries] Waiting for FusionAuth server to start... " 27 | 28 | if isFusionAuthReady; then 29 | echo "READY" 30 | exit 0 31 | fi 32 | 33 | echo "NOT READY" 34 | sleep 5 35 | i=$((i + 1)) 36 | done 37 | 38 | exit 1 -------------------------------------------------------------------------------- /src/examples/python/create_and_register_user.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from fusionauth.fusionauth_client import FusionAuthClient 3 | 4 | 5 | # You must supply your API key and URL here 6 | client = FusionAuthClient('api-key', 'http://localhost:9011') 7 | # You must supply your Application Id here 8 | application_id='application-id' 9 | 10 | # Here we create a user and register them to our application in a single request 11 | # This can alternatively be achieved in two steps, first creating the user, then registering them 12 | user_registration_request = { 13 | 'registration': { 14 | 'applicationId': application_id, 15 | 'roles': [ 16 | 'user', 17 | 'community_helper' 18 | ] 19 | }, 20 | 'user': { 21 | 'birthDate': '1976-05-30', 22 | 'email': 'john@doe.io', 23 | 'password': 'password', 24 | 'firstName': 'John', 25 | 'lastName': 'Doe', 26 | 'twoFactorEnabled': False, 27 | 'username': 'johnny123' 28 | }, 29 | 'sendSetPasswordEmail': False, 30 | 'skipVerification': False 31 | } 32 | 33 | client_response = client.register(user_registration_request) 34 | if client_response.was_successful(): 35 | print(client_response.success_response) 36 | else: 37 | sys.exit(client_response.error_response) 38 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | # Run locally with act: 2 | # 3 | # act pull_request --workflows .github/workflows/test.yaml 4 | 5 | name: Test 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | - develop 12 | pull_request: 13 | workflow_dispatch: 14 | 15 | jobs: 16 | run_tests: 17 | runs-on: ubuntu-latest 18 | strategy: 19 | matrix: 20 | version: 21 | - '3.8' 22 | - '3.9' 23 | - '3.10' 24 | - '3.11' 25 | - '3.12' 26 | env: 27 | FUSIONAUTH_URL: http://localhost:9011 28 | FUSIONAUTH_API_KEY: bf69486b-4733-4470-a592-f1bfce7af580 29 | steps: 30 | - uses: actions/checkout@v4 31 | 32 | - uses: actions/setup-python@v5 33 | with: 34 | python-version: ${{ matrix.version }} 35 | 36 | - name: Set up FusionAuth 37 | working-directory: src/test/docker 38 | run: docker compose up -d 39 | 40 | - name: Check to see if FusionAuth is loaded 41 | run: | 42 | bash ./src/test/docker/poll-for-kickstart-finish.sh 43 | 44 | - name: Run tests 45 | shell: bash -l {0} 46 | run: | 47 | python3 -m venv .venv 48 | source .venv/bin/activate 49 | echo -e "\nUsing $(python --version) in $(which python)\n" 50 | pip install -e . 51 | echo "" 52 | pip list 53 | echo "" 54 | python src/test/python/fusionauth/rest_client_test.py 55 | python src/test/python/fusionauth/fusionauth_client_test.py 56 | -------------------------------------------------------------------------------- /src/test/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | image: postgres:16.4-alpine 4 | environment: 5 | PGDATA: /var/lib/postgresql/data/pgdata 6 | POSTGRES_USER: postgres 7 | POSTGRES_PASSWORD: postgres 8 | healthcheck: 9 | test: [ "CMD-SHELL", "pg_isready -U postgres" ] 10 | interval: 5s 11 | timeout: 5s 12 | retries: 5 13 | networks: 14 | - db_net 15 | restart: unless-stopped 16 | volumes: 17 | - db_data:/var/lib/postgresql/data 18 | 19 | fusionauth: 20 | image: fusionauth/fusionauth-app:latest 21 | depends_on: 22 | db: 23 | condition: service_healthy 24 | environment: 25 | DATABASE_URL: jdbc:postgresql://db:5432/fusionauth 26 | DATABASE_ROOT_USERNAME: postgres 27 | DATABASE_ROOT_PASSWORD: postgres 28 | DATABASE_USERNAME: fusionauth 29 | DATABASE_PASSWORD: fusionauth 30 | FUSIONAUTH_APP_MEMORY: 512M 31 | FUSIONAUTH_APP_RUNTIME_MODE: development 32 | FUSIONAUTH_APP_SILENT_MODE: true 33 | FUSIONAUTH_APP_URL: http://fusionauth:9011 34 | FUSIONAUTH_APP_KICKSTART_FILE: /usr/local/fusionauth/kickstart/kickstart.json 35 | SEARCH_TYPE: database 36 | networks: 37 | - db_net 38 | restart: unless-stopped 39 | ports: 40 | - 9011:9011 41 | volumes: 42 | - fusionauth_config:/usr/local/fusionauth/config 43 | - ./kickstart:/usr/local/fusionauth/kickstart 44 | healthcheck: 45 | test: curl --silent --fail http://localhost:9011/api/status -o /dev/null -w "%{http_code}" 46 | interval: 5s 47 | timeout: 5s 48 | retries: 5 49 | 50 | networks: 51 | db_net: 52 | driver: bridge 53 | 54 | volumes: 55 | db_data: 56 | fusionauth_config: 57 | -------------------------------------------------------------------------------- /src/test/python/fusionauth/rest_client_test.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016-2024, FusionAuth, All Rights Reserved 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, 11 | # software distributed under the License is distributed on an 12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 13 | # either express or implied. See the License for the specific 14 | # language governing permissions and limitations under the License. 15 | # 16 | 17 | import json 18 | import os 19 | import uuid 20 | 21 | import unittest 22 | 23 | from fusionauth.rest_client import RESTClient 24 | 25 | 26 | def print_json(parsed_json): 27 | print(json.dumps(parsed_json, indent=2, sort_keys=True)) 28 | 29 | 30 | class RestClientTest(unittest.TestCase): 31 | def setUp(self): 32 | pass 33 | 34 | def runTest(self): 35 | pass 36 | 37 | def test_uri_with_path_with_slash_prefix(self): 38 | client = RESTClient() 39 | client.url('http://example.com') 40 | self.assertEqual(client.uri('/example/path')._url, 'http://example.com/example/path') 41 | 42 | def test_uri_with_path_with_no_slash_prefix(self): 43 | client = RESTClient() 44 | client.url('http://example.com') 45 | self.assertEqual(client.uri('example/path')._url, 'http://example.com/example/path') 46 | 47 | def test_uri_with_slash_suffix_with_path_with_slash_prefix(self): 48 | client = RESTClient() 49 | client.url('http://example.com/') 50 | self.assertEqual(client.uri('/example/path')._url, 'http://example.com/example/path') 51 | 52 | def test_uri_with_slash_suffix_with_path_with_no_slash_prefix(self): 53 | client = RESTClient() 54 | client.url('http://example.com/') 55 | self.assertEqual(client.uri('example/path')._url, 'http://example.com/example/path') 56 | 57 | 58 | if __name__ == '__main__': 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Deploy 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | command: 8 | type: choice 9 | options: 10 | - publish # build & publish to pypi 11 | - release # build & release to svn 12 | default: publish 13 | 14 | permissions: 15 | contents: read 16 | id-token: write 17 | 18 | jobs: 19 | deploy: 20 | runs-on: ubuntu-latest 21 | defaults: 22 | run: 23 | shell: /usr/bin/bash -l -e -o pipefail {0} 24 | steps: 25 | - name: checkout 26 | uses: actions/checkout@v4 27 | 28 | - name: setup python 29 | uses: actions/setup-python@v5 30 | with: 31 | python-version: 3.12.6 32 | 33 | - name: setup java 34 | uses: actions/setup-java@v4 35 | with: 36 | distribution: temurin 37 | java-version: 21 38 | java-package: jre 39 | 40 | - name: install savant 41 | run: | 42 | curl -O https://repository.savantbuild.org/org/savantbuild/savant-core/2.0.0/savant-2.0.0.tar.gz 43 | tar xzvf savant-2.0.0.tar.gz 44 | savant-2.0.0/bin/sb --version 45 | SAVANT_PATH=$(realpath -s "./savant-2.0.0/bin") 46 | echo "${SAVANT_PATH}" >> $GITHUB_PATH 47 | mkdir -p ~/.savant/plugins 48 | cat << EOF > ~/.savant/plugins/org.savantbuild.plugin.java.properties 49 | 21=${JAVA_HOME} 50 | EOF 51 | 52 | - name: set aws credentials 53 | uses: aws-actions/configure-aws-credentials@v4 54 | with: 55 | role-to-assume: arn:aws:iam::752443094709:role/gha-fusionauth-python-client 56 | role-session-name: aws-auth-action 57 | aws-region: us-west-2 58 | 59 | - name: get secret 60 | run: | 61 | while IFS=$'\t' read -r key value; do 62 | echo "::add-mask::${value}" 63 | echo "${key}=${value}" >> $GITHUB_ENV 64 | done < <(aws secretsmanager get-secret-value \ 65 | --region us-west-2 \ 66 | --secret-id platform/pypi \ 67 | --query SecretString \ 68 | --output text | \ 69 | jq -r 'to_entries[] | [.key, .value] | @tsv') 70 | 71 | - name: set pypi credentials 72 | run: | 73 | cat << EOF > ~/.pypirc 74 | [distutils] 75 | index-servers = 76 | pypi 77 | fusionauth-client 78 | [pypi] 79 | username = __token__ 80 | password = ${{ env.API_KEY }} 81 | [fusionauth-client] 82 | repository = https://upload.pypi.org/legacy/ 83 | username = __token__ 84 | password = ${{ env.API_KEY }} 85 | EOF 86 | 87 | - name: release to svn 88 | if: inputs.command == 'release' 89 | run: sb release 90 | 91 | - name: publish to pypi 92 | if: inputs.command == 'publish' 93 | run: sb publish 94 | -------------------------------------------------------------------------------- /src/examples/python/bulk_import.py: -------------------------------------------------------------------------------- 1 | import simplejson as json 2 | import uuid 3 | import psycopg2 4 | import requests 5 | 6 | from datetime import date 7 | 8 | # Example bulk import script to import users from an existing table into FusionAuth using the bulk import API 9 | # 10 | # Setup 11 | # 1. Create a FusionAuth application, make note of the application Id. 12 | # 13 | # 2. Add the following roles to the application 14 | # - user 15 | # 16 | # 3. Add an API key if you don't already have one - FusionAuth --> Settings --> API Keys 17 | # - It must at least have [POST] permission to /api/user/import 18 | # 19 | # 4. Update the configurable parameters below. 20 | 21 | # Start - Configurable parameters 22 | db_name = "application" 23 | db_user = "dev" 24 | db_table = "users" 25 | 26 | api_uri = "http://localhost:9011/api/user/import" 27 | api_headers = { 28 | 'Authorization': 'api-key', 29 | 'Content-Type': 'application/json' 30 | } 31 | application_id = "1141e0b8-95e6-402a-ac6f-0a0449485b3c" 32 | # End - Configurable parameters 33 | 34 | # Connect to db 35 | conn = psycopg2.connect("dbname=%s user=%s" % (db_name, db_user)) 36 | cur = conn.cursor() 37 | 38 | # Retrieve all and assign them to 'result' 39 | cur.execute("SELECT * from %s" % db_table) 40 | result = cur.fetchall() 41 | 42 | 43 | # Example Table definition, modify to match yours 44 | # -------------------- 45 | # 0 id 46 | # 1 password [ scheme | factor | salt | hash ] 47 | # 2 last_login 48 | # 3 username 49 | # 4 first_name 50 | # 5 last_name 51 | # 6 email 52 | # 7 active 53 | # 8 created 54 | # 9 last_modified 55 | # 10 date_of_birth 56 | # 11 parent_id 57 | 58 | # Build JSON Body 59 | request = {'users': []} 60 | for index, row in enumerate(result): 61 | schema = row[1].split("$") 62 | encryption_scheme = "salted-pbkdf2-hmac-sha256" if schema[0] == "pbkdf2_sha256" else schema[0] 63 | 64 | user = { 65 | 'id': uuid.UUID(int=row[0]), 66 | 'active': row[7], 67 | 'encryptionScheme': encryption_scheme, 68 | 'factor': schema[1], 69 | 'salt': schema[2], 70 | 'password': schema[3], 71 | 'email': row[6], 72 | 'username': row[3], 73 | 'firstName': row[4], 74 | 'lastName': row[5], 75 | 'birthDate': row[10], 76 | 'registrations': [{ 77 | 'applicationId': application_id, 78 | 'roles': ['user'] 79 | }], 80 | } 81 | 82 | # prune empty properties 83 | user = dict((k, v) for k, v in user.iteritems() if v is not None and v != "") 84 | request['users'].append(user) 85 | 86 | 87 | # Custom Encoder to handle UUID and date 88 | def custom_encoder(obj): 89 | if isinstance(obj, uuid.UUID): 90 | return str(obj) 91 | if isinstance(obj, date): 92 | return str(obj) 93 | 94 | 95 | # Build Json Request 96 | json_data = json.dumps(request, default=custom_encoder) 97 | 98 | # Make the API call to bulk import 99 | response = requests.post(api_uri, data=json_data, headers=api_headers) 100 | print "API Response [%d]" % response.status_code 101 | 102 | if response.status_code == 400: 103 | print 'Error Response: ' 104 | print response.json() 105 | -------------------------------------------------------------------------------- /src/test/docker/kickstart/kickstart.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "adminEmail": "admin@fusionauth.io", 4 | "password": "password", 5 | "defaultTenantId": "30663132-6464-6665-3032-326466613934", 6 | "piedPiperApplicationId": "85a03867-dccf-4882-adde-1a79aeec50df" 7 | }, 8 | "apiKeys": [ 9 | { 10 | "key": "bf69486b-4733-4470-a592-f1bfce7af580", 11 | "description": "Standard development API key" 12 | } 13 | ], 14 | "requests": [ 15 | { 16 | "method": "POST", 17 | "url": "/api/application/#{piedPiperApplicationId}", 18 | "body": { 19 | "application": { 20 | "name": "Pied Piper", 21 | "roles": [ 22 | { 23 | "name": "dev" 24 | }, 25 | { 26 | "name": "ceo" 27 | }, 28 | { 29 | "name": "intern" 30 | } 31 | ], 32 | "loginConfiguration": { 33 | "generateRefreshTokens": true 34 | } 35 | } 36 | } 37 | }, 38 | { 39 | "method": "POST", 40 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000001", 41 | "body": { 42 | "user": { 43 | "birthDate": "1981-06-04", 44 | "email": "#{adminEmail}", 45 | "firstName": "Erlich", 46 | "lastName": "Bachman", 47 | "password": "#{password}", 48 | "data": { 49 | "Company": "PiedPiper", 50 | "PreviousCompany": "Aviato", 51 | "user_type": "iconclast" 52 | } 53 | }, 54 | "registration": { 55 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 56 | "roles": [ 57 | "admin" 58 | ] 59 | } 60 | } 61 | }, 62 | { 63 | "method": "POST", 64 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000001", 65 | "body": { 66 | "registration": { 67 | "applicationId": "#{piedPiperApplicationId}" 68 | } 69 | } 70 | }, 71 | { 72 | "method": "POST", 73 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000002", 74 | "body": { 75 | "user": { 76 | "email": "jared@fusionauth.io", 77 | "firstName": "Jared", 78 | "lastName": "Dunn", 79 | "password": "#{password}", 80 | "data": { 81 | "Company": "PiedPiper" 82 | }, 83 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-jared.png" 84 | }, 85 | "registration": { 86 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 87 | "roles": [ 88 | "admin" 89 | ] 90 | } 91 | } 92 | }, 93 | { 94 | "method": "POST", 95 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000003", 96 | "body": { 97 | "user": { 98 | "email": "nelson@fusionauth.io", 99 | "firstName": "Nelson", 100 | "lastName": "Bighetti", 101 | "password": "#{password}", 102 | "data": { 103 | "Company": "PiedPiper" 104 | }, 105 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-big-head.png" 106 | }, 107 | "registration": { 108 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 109 | "roles": [ 110 | "admin" 111 | ] 112 | } 113 | } 114 | }, 115 | { 116 | "method": "POST", 117 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000004", 118 | "body": { 119 | "user": { 120 | "email": "dinesh@fusionauth.io", 121 | "firstName": "Dinish", 122 | "lastName": "Chugtai", 123 | "password": "#{password}", 124 | "data": { 125 | "Company": "PiedPiper" 126 | }, 127 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-dinesh.png" 128 | }, 129 | "registration": { 130 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 131 | "roles": [ 132 | "admin" 133 | ] 134 | } 135 | } 136 | }, 137 | { 138 | "method": "POST", 139 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000005", 140 | "body": { 141 | "user": { 142 | "email": "gilfoyle@fusionauth.io", 143 | "firstName": "Bertram", 144 | "lastName": "Gilfoyle", 145 | "password": "#{password}", 146 | "data": { 147 | "Company": "PiedPiper" 148 | }, 149 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-gilfoyle.png" 150 | }, 151 | "registration": { 152 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 153 | "roles": [ 154 | "admin" 155 | ] 156 | } 157 | } 158 | }, 159 | { 160 | "method": "POST", 161 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000006", 162 | "body": { 163 | "user": { 164 | "email": "richard@fusionauth.io", 165 | "firstName": "Richard", 166 | "lastName": "Hendricks", 167 | "password": "#{password}", 168 | "data": { 169 | "Company": "PiedPiper" 170 | }, 171 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-richard.png" 172 | }, 173 | "registration": { 174 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 175 | "roles": [ 176 | "admin" 177 | ] 178 | } 179 | } 180 | }, 181 | { 182 | "method": "POST", 183 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000007", 184 | "body": { 185 | "user": { 186 | "email": "monica@fusionauth.io", 187 | "firstName": "Monica", 188 | "lastName": "Hall", 189 | "password": "#{password}", 190 | "data": { 191 | "Company": "PiedPiper" 192 | }, 193 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-monica.png" 194 | }, 195 | "registration": { 196 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 197 | "roles": [ 198 | "admin" 199 | ] 200 | } 201 | } 202 | }, 203 | { 204 | "method": "POST", 205 | "url": "/api/user/registration/00000000-0000-0000-0000-000000000008", 206 | "body": { 207 | "user": { 208 | "email": "jian@fusionauth.io", 209 | "firstName": "Jìan", 210 | "lastName": "Yáng", 211 | "password": "#{password}", 212 | "data": { 213 | "Company": "PiedPiper" 214 | }, 215 | "imageUrl": "https://local.fusionauth.io/images/doc-profile-pictures/photo-jian-yang.png" 216 | }, 217 | "registration": { 218 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 219 | "roles": [ 220 | "admin" 221 | ] 222 | } 223 | } 224 | } 225 | ] 226 | } 227 | -------------------------------------------------------------------------------- /src/main/python/fusionauth/rest_client.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016-2018, FusionAuth, All Rights Reserved 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, 11 | # software distributed under the License is distributed on an 12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 13 | # either express or implied. See the License for the specific 14 | # language governing permissions and limitations under the License. 15 | # 16 | 17 | import base64 18 | import json 19 | 20 | import requests 21 | 22 | 23 | class RESTClient: 24 | """The RestClient used to build API calls to FusionAuth. 25 | 26 | Attributes: 27 | _headers: The headers 28 | _parameters: The parameters 29 | _url: The url 30 | _body_handler: A delegate to get the body of the request 31 | _certificate: The certificate 32 | _method: The method 33 | """ 34 | 35 | def __init__(self): 36 | self._url = None 37 | self._parameters = {} 38 | self._proxy = {} 39 | self._headers = {} 40 | self._body_handler = None 41 | self._certificate = None 42 | self._connect_timeout = 1000 43 | self._error_response_handler = None 44 | self._error_type = None 45 | self._method = None 46 | self._success_response_handler = None 47 | 48 | def authorization(self, authorization): 49 | self._headers['Authorization'] = authorization 50 | return self 51 | 52 | def basic_authorization(self, username, password): 53 | if username and password: 54 | self.header('Authorization', 'Basic ' + base64.urlsafe_b64encode(username + ':' + password)) 55 | return self 56 | 57 | def body_handler(self, handler): 58 | self._body_handler = handler 59 | return self 60 | 61 | def certificate(self, certificate): 62 | self._certificate = certificate 63 | return self 64 | 65 | def connect_timeout(self, connect_timeout): 66 | self._connect_timeout = connect_timeout 67 | return self 68 | 69 | def delete(self): 70 | self._method = 'DELETE' 71 | return self 72 | 73 | def error_response_handler(self, error_response_handler): 74 | self._error_response_handler = error_response_handler 75 | return self 76 | 77 | def get(self): 78 | self._method = 'GET' 79 | return self 80 | 81 | def patch(self): 82 | self._method = 'PATCH' 83 | return self 84 | 85 | def post(self): 86 | self._method = 'POST' 87 | return self 88 | 89 | def put(self): 90 | self._method = 'PUT' 91 | return self 92 | 93 | def go(self): 94 | if self._method is None: 95 | raise ValueError('The HTTP method must be set prior to calling go()') 96 | 97 | if self._url is None or len(self._url) == 0: 98 | raise ValueError('You must specify a URL') 99 | 100 | if self._body_handler is not None: 101 | self._body_handler.set_headers(self._headers) 102 | 103 | data = self._body_handler.get_body() if self._body_handler is not None else None 104 | 105 | return ClientResponse( 106 | requests.request(self._method, self._url, headers=self._headers, params=self._parameters, data=data, cert=self._certificate, 107 | timeout=self._connect_timeout, proxies=self._proxy)) 108 | 109 | def header(self, key, value): 110 | self._headers[key] = value 111 | return self 112 | 113 | def headers(self, headers): 114 | self._headers.update(headers) 115 | return self 116 | 117 | def success_response_handler(self, success_response_handler): 118 | self._success_response_handler = success_response_handler 119 | return self 120 | 121 | def uri(self, uri): 122 | if self._url is None: 123 | return self 124 | 125 | if self._url.endswith('/') and uri.startswith('/'): 126 | self._url += uri[1:] 127 | elif not self._url.endswith('/') and not uri.startswith('/'): 128 | self._url += "/" + uri 129 | else: 130 | self._url += uri 131 | return self 132 | 133 | def url(self, url): 134 | self._url = url 135 | return self 136 | 137 | def url_parameter(self, name, value): 138 | if value is None: 139 | return self 140 | 141 | values = self._parameters.get(name) 142 | if values is None: 143 | values = [] 144 | self._parameters[name] = values 145 | 146 | values.append(value) 147 | return self 148 | 149 | def url_segment(self, segment): 150 | if segment is not None: 151 | if not self._url.endswith('/'): 152 | self._url += '/' 153 | 154 | self._url += segment if type(segment) is str else str(segment) 155 | 156 | return self 157 | 158 | 159 | class ClientResponse: 160 | """The ClientResponse returned from the the FusionAuth API. 161 | 162 | Attributes: 163 | error_response: 164 | exception: 165 | response: The full response object 166 | success_response: 167 | status: 168 | """ 169 | 170 | def __init__(self, response, streaming=False): 171 | self.error_response = None 172 | self.exception = None 173 | self.response = response 174 | self.success_response = None 175 | self.status = response.status_code 176 | 177 | if self.status < 200 or self.status > 299: 178 | if self.response.content is not None and self.status != 404: 179 | if self.status == 400: 180 | self.error_response = self.response.json() 181 | else: 182 | self.error_response = self.response 183 | elif not streaming: 184 | try: 185 | self.success_response = self.response.json() 186 | except ValueError: 187 | self.success_response = None 188 | 189 | def was_successful(self): 190 | return 200 <= self.status <= 299 and self.exception is None 191 | 192 | def write_response_to_file(self, file): 193 | with open(file, 'wb') as f: 194 | for chunk in self.response: 195 | f.write(chunk) 196 | 197 | 198 | class JSONBodyHandler: 199 | def __init__(self, body_object): 200 | self._body = json.dumps(body_object) 201 | 202 | def set_headers(self, headers): 203 | headers['Length'] = str(len(self._body.encode('utf-8'))) 204 | headers['Content-Type'] = "application/json" 205 | 206 | def get_body(self): 207 | return self._body 208 | 209 | class FormDataBodyHandler: 210 | def __init__(self, body_object): 211 | self._body = body_object 212 | 213 | def set_headers(self, headers): 214 | headers['Content-Type'] = "application/x-www-form-urlencoded" 215 | 216 | def get_body(self): 217 | return self._body 218 | -------------------------------------------------------------------------------- /src/test/python/fusionauth/fusionauth_client_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025, FusionAuth, All Rights Reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an 11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | # either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | # Licensed under the Apache License, Version 2.0 (the "License"); 16 | # you may not use this file except in compliance with the License. 17 | # You may obtain a copy of the License at 18 | # 19 | # http://www.apache.org/licenses/LICENSE-2.0 20 | # 21 | # Unless required by applicable law or agreed to in writing, 22 | # software distributed under the License is distributed on an 23 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 24 | # either express or implied. See the License for the specific 25 | # language governing permissions and limitations under the License. 26 | # 27 | # Licensed under the Apache License, Version 2.0 (the "License"); 28 | # you may not use this file except in compliance with the License. 29 | # You may obtain a copy of the License at 30 | # 31 | # http://www.apache.org/licenses/LICENSE-2.0 32 | # 33 | # Unless required by applicable law or agreed to in writing, 34 | # software distributed under the License is distributed on an 35 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 36 | # either express or implied. See the License for the specific 37 | # language governing permissions and limitations under the License. 38 | # 39 | # Licensed under the Apache License, Version 2.0 (the "License"); 40 | # you may not use this file except in compliance with the License. 41 | # You may obtain a copy of the License at 42 | # 43 | # http://www.apache.org/licenses/LICENSE-2.0 44 | # 45 | # Unless required by applicable law or agreed to in writing, 46 | # software distributed under the License is distributed on an 47 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 48 | # either express or implied. See the License for the specific 49 | # language governing permissions and limitations under the License. 50 | 51 | import json 52 | import os 53 | import unittest 54 | import uuid 55 | 56 | from fusionauth.fusionauth_client import FusionAuthClient 57 | 58 | 59 | def print_json(parsed_json): 60 | print(json.dumps(parsed_json, indent=2, sort_keys=True)) 61 | 62 | 63 | class FusionAuthClientTest(unittest.TestCase): 64 | def setUp(self): 65 | fusionauth_url = os.getenv('FUSIONAUTH_URL') if 'FUSIONAUTH_URL' in os.environ else 'http://localhost:9011' 66 | fusionauth_api_key = os.getenv( 67 | 'FUSIONAUTH_API_KEY') if 'FUSIONAUTH_API_KEY' in os.environ else 'bf69486b-4733-4470-a592-f1bfce7af580' 68 | self.client = FusionAuthClient(fusionauth_api_key, fusionauth_url) 69 | self.anonymous_client = FusionAuthClient('', fusionauth_url) 70 | 71 | def runTest(self): 72 | pass 73 | 74 | def test_retrieve_applications(self): 75 | client_response = self.client.retrieve_applications() 76 | self.assertEqual(client_response.status, 200) 77 | # tnent manager is 1 application, admin is another, Pied piper in the kickstart is the 3rd. 78 | self.assertEqual(len(client_response.success_response['applications']), 3) 79 | 80 | def test_create_user_retrieve_user(self): 81 | # Check if the user already exists. 82 | get_user_response = self.client.retrieve_user_by_email('user@example.com') 83 | if get_user_response.status == 200: 84 | delete_user_response = self.client.delete_user(get_user_response.success_response['user']['id']) 85 | self.assertEqual(delete_user_response.status, 200, delete_user_response.error_response) 86 | else: 87 | self.assertEqual(get_user_response.status, 404, get_user_response.error_response) 88 | 89 | # Create a new registration for this user. 90 | user_request = { 91 | 'sendSetPasswordEmail': False, 92 | 'skipVerification': True, 93 | 'user': { 94 | 'email': 'user@example.com', 95 | 'password': 'password' 96 | } 97 | } 98 | create_user_response = self.client.create_user(user_request) 99 | self.assertEqual(create_user_response.status, 200, create_user_response.error_response) 100 | 101 | # Retrieve the user 102 | user_id = create_user_response.success_response['user']['id'] 103 | get_user_response = self.client.retrieve_user(user_id) 104 | self.assertEqual(get_user_response.status, 200) 105 | self.assertIsNotNone(get_user_response.success_response) 106 | self.assertIsNone(get_user_response.error_response) 107 | self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') 108 | self.assertFalse('password' in get_user_response.success_response['user']) 109 | self.assertFalse('salt' in get_user_response.success_response['user']) 110 | 111 | # Retrieve the user via loginId 112 | get_user_response = self.client.retrieve_user_by_login_id('user@example.com') 113 | self.assertEqual(get_user_response.status, 200) 114 | self.assertIsNotNone(get_user_response.success_response) 115 | self.assertIsNone(get_user_response.error_response) 116 | self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') 117 | 118 | # Explicit loginIdType 119 | get_user_response = self.client.retrieve_user_by_login_id_with_login_id_types('user@example.com', ['email']) 120 | self.assertEqual(get_user_response.status, 200) 121 | self.assertIsNotNone(get_user_response.success_response) 122 | self.assertIsNone(get_user_response.error_response) 123 | self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') 124 | 125 | # TODO: Once issue 1 is released, this test should pass 126 | # # wrong loginIdType 127 | # get_user_response = self.client.retrieve_user_by_login_id_with_login_id_types('user@example.com', ['phoneNumber']) 128 | # self.assertEqual(get_user_response.status, 404) 129 | 130 | def test_retrieve_user_missing(self): 131 | user_id = uuid.uuid4() 132 | client_response = self.client.retrieve_user(user_id) 133 | self.assertEqual(client_response.status, 404) 134 | self.assertIsNone(client_response.success_response) 135 | self.assertIsNone(client_response.error_response) 136 | 137 | def test_login_user_logout_global(self): 138 | login_request = { 139 | 'loginId': 'admin@fusionauth.io', 140 | 'password': 'password', 141 | 'applicationId': '85a03867-dccf-4882-adde-1a79aeec50df' 142 | } 143 | login_response = self.client.login(login_request) 144 | self.assertEqual(login_response.status, 200, login_response.error_response) 145 | 146 | refreshToken = login_response.success_response['refreshToken'] 147 | 148 | logout_response = self.anonymous_client.logout(True, refreshToken) 149 | 150 | self.assertEqual(logout_response.status, 200, logout_response.error_response) 151 | 152 | 153 | if __name__ == '__main__': 154 | unittest.main() 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FusionAuth Python Client ![semver 2.0.0 compliant](http://img.shields.io/badge/semver-2.0.0-brightgreen.svg?style=flat-square) 2 | 3 | ## Intro 4 | 5 | 8 | 9 | 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](https://fusionauth.io/docs/sdks/#usage-suggestions). 10 | 11 | For additional information and documentation on FusionAuth refer to [https://fusionauth.io](https://fusionauth.io). 12 | 13 | ## Install 14 | To install the FusionAuth Python Client package run: 15 | 16 | ```bash 17 | pip install fusionauth-client 18 | ``` 19 | 20 | This library can be found on PyPI at https://pypi.org/project/fusionauth-client/. 21 | 22 | ## Examples 23 | 24 | ### Set Up 25 | 26 | 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](https://fusionauth.io/docs/get-started/download-and-install/docker), but there are [other ways](https://fusionauth.io/docs/get-started/download-and-install). By default, it'll be running on `localhost:9011`. 27 | 28 | Then, you have to [create an API Key](https://fusionauth.io/docs/apis/authentication#managing-api-keys) in the admin UI to allow calling API endpoints. 29 | 30 | You are now ready to use this library. 31 | 32 | ### Create the Client 33 | 34 | Include the package in your code by using the following statement. 35 | 36 | ```python 37 | from fusionauth.fusionauth_client import FusionAuthClient 38 | ``` 39 | 40 | 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`. 41 | 42 | ```python 43 | client = FusionAuthClient('6b87a398-39f2-4692-927b-13188a81a9a3', 'http://localhost:9011') 44 | ``` 45 | 46 | ### Error Handling 47 | 48 | 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. 49 | 50 | 51 | ### Create an Application 52 | 53 | To create an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use the `create_application()` method. 54 | 55 | ```python 56 | data = { 57 | 'application': { 58 | 'name': 'ChangeBank' 59 | } 60 | } 61 | 62 | result = client.create_application(data) 63 | 64 | # Handle errors as shown in the beginning of the Examples section 65 | 66 | # Otherwise parse the successful response 67 | print(result.success_response) 68 | ``` 69 | 70 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#create-an-application) 71 | 72 | ### Adding Roles to an Existing Application 73 | 74 | To add [roles to an Application](https://fusionauth.io/docs/get-started/core-concepts/applications#roles), use `create_application_role()`. 75 | 76 | ```python 77 | data = { 78 | 'role': { 79 | 'name': 'customer', 80 | 'description': 'Default role for regular customers', 81 | 'isDefault': 1 82 | } 83 | } 84 | 85 | result = client.create_application_role( 86 | application_id='5a89377e-a250-4b15-b766-377ecc9b9fc9', 87 | request=data 88 | ) 89 | 90 | # Handle errors as shown in the beginning of the Examples section 91 | 92 | # Otherwise parse the successful response 93 | print(result.success_response) 94 | ``` 95 | 96 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#create-an-application-role) 97 | 98 | ### Retrieve Application Details 99 | 100 | To fetch details about an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use `retrieve_application()`. 101 | 102 | ```python 103 | result = client.retrieve_application( 104 | application_id='5a89377e-a250-4b15-b766-377ecc9b9fc9' 105 | ) 106 | print(result.success_response) 107 | ``` 108 | 109 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#retrieve-an-application) 110 | 111 | ### Delete an Application 112 | 113 | To delete an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use `delete_application()`. 114 | 115 | ```python 116 | client.delete_application( 117 | application_id='5a89377e-a250-4b15-b766-377ecc9b9fc9' 118 | ) 119 | ``` 120 | 121 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#delete-an-application) 122 | 123 | ### Lock a User 124 | 125 | To [prevent a User from logging in](https://fusionauth.io/docs/get-started/core-concepts/users), use `deactivate_user()`. 126 | 127 | ```python 128 | client.deactivate_user( 129 | user_id='231b982c-9304-4642-9bac-492d6917f5aa' 130 | ) 131 | ``` 132 | 133 | 134 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/users#delete-a-user) 135 | 136 | ### Registering a User 137 | 138 | To [register a User in an Application](https://fusionauth.io/docs/get-started/core-concepts/users#registrations), use `register()`. 139 | 140 | The code below also adds a `customer` role and a custom `appBackgroundColor` property to the User Registration. 141 | 142 | ```python 143 | result = client.register( 144 | user_id='231b982c-9304-4642-9bac-492d6917f5aa', 145 | request={ 146 | 'registration': { 147 | 'applicationId': '5a89377e-a250-4b15-b766-377ecc9b9fc9', 148 | 'roles': [ 149 | 'customer' 150 | ], 151 | 'data': { 152 | 'appBackgroundColor': '#096324' 153 | } 154 | } 155 | } 156 | ) 157 | print(result.success_response) 158 | ``` 159 | 160 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/registrations#create-a-user-registration-for-an-existing-user) 161 | 162 | 165 | 166 | 167 | 168 | ## Questions and support 169 | 170 | If you find any bugs in this library, [please open an issue](https://github.com/FusionAuth/fusionauth-python-client/issues). Note that changes to the `FusionAuthClient` class have to be done on the [FusionAuth Client Builder repository](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/python.client.ftl), which is responsible for generating that file. 171 | 172 | But if you have a question or support issue, we'd love to hear from you. 173 | 174 | If you have a paid plan with support included, please [open a ticket in your account portal](https://account.fusionauth.io/account/support/). Learn more about [paid plan here](https://fusionauth.io/pricing). 175 | 176 | Otherwise, please [post your question in the community forum](https://fusionauth.io/community/forum/). 177 | 178 | ## Contributing 179 | 180 | Bug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/fusionauth-python-client. 181 | 182 | Note: if you want to change the `FusionAuthClient` class, you have to do it on the [FusionAuth Client Builder repository](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/python.client.ftl), which is responsible for generating all client libraries we support. 183 | 184 | ## License 185 | 186 | This code is available as open source under the terms of the [Apache v2.0 License](https://opensource.org/license/apache-2-0). 187 | 188 | ## Upgrade Policy 189 | 190 | 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. 191 | 192 | 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. 193 | 194 | 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. 195 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------