Hello World Authentication

chevron-rightPrerequisiteshashtag
  • Python 3.11 or higher

  • Poetry 1.8.1 or higher (recommended)

  • Docker (make sure the Docker daemon is running and you have permission to use Docker)

BOSA Authentication Example App

circle-info

All the code used in the following examples can be found in our GitHub repository bosa-example-apps/bosa-authentication-example-apparrow-up-right.

git clone https://github.com/GDP-ADMIN/bosa-example-apps.git
cd bosa-authentication-example-app

▶️ Execute the script for installing and start the dependencies

./start-dependencies.sh

⬆️ This script will do the following:

  • Check that required commands (Python and Poetry) are installed and meet specified version requirements.

  • Copy configuration .env files from templates if they do not already exist.

  • Deactivate any active Conda environments to avoid conflicts.

  • Install project dependencies using a Makefile.

  • Start project dependencies (like Docker containers) as required for the application to run.

🚀 Then run the app

🛑 Run this script for stop the running dependencies:

Here's the endpoints for our example apps FastAPI (or you can open http://localhost:8000/docs) for you to play around.

API Endpoints

Client Management

Create Client

  • POST /client

  • Body: {"name": "My App"}

  • Response: Client object with API key

Verify Client API Key

  • GET /client/verify

  • Headers: x-api-key

  • Response: {"valid_key": true/false}

User Management

Create User

  • POST /users

  • Headers: x-api-key

  • Body: {"identifier": "user@example.com"}

  • Response: User object

Get User by Identifier

  • GET /users/{identifier}

  • Headers: x-api-key

  • Response: User object

Get User with Integrations

  • GET /users/integrations

  • Headers: x-api-key, Authorization: Bearer {token}

  • Response: Complete user object with integrations

Authentication

Authenticate User (Login)

  • POST /users/authenticate

  • Headers: x-api-key

  • Body: {"identifier": "user@example.com", "secret": "password"}

  • Response: Access token and user info

Verify Token

  • GET /users/verify

  • Headers: x-api-key, Authorization: Bearer {token}

  • Response: {"user_id": "user_123"}

Revoke Token (Logout)

  • POST /users/revoke

  • Headers: x-api-key, Authorization: Bearer {token}

  • Response: Success message

Last updated