Skip to content

timoles/api_flask_python_hello-world

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello World API: Flask Auth0 Sample

This Python code sample demonstrates how to implement authorization in a Flask API server using Auth0.

Run the Project

Create a virtual environment under the root project directory:

macOS/Linux:

python3 -m venv venv

Windows:

py -3 -m venv venv

Activate the virtual environment:

macOS/Linux:

. venv/bin/activate

Windows:

venv\Scripts\activate

Install the project dependencies:

pip install -r requirements.txt

Create a .env file under the root project directory and populate it with the following content:

CLIENT_ORIGIN_URL=http://localhost:4040
AUTH0_AUDIENCE=
AUTH0_DOMAIN=

Run the project in development mode:

flask run

API Endpoints

The API server defines the following endpoints:

🔓 Get public message

GET /api/messages/public

Response

Status: 200 OK
{
  "message": "The API doesn't require an access token to share this message."
}

🔐 Get protected message

GET /api/messages/protected

Response

Status: 200 OK
{
  "message": "The API successfully validated your access token."
}

🔐 Get admin message

GET /api/messages/admin

Response

Status: 200 OK
{
  "message": "The API successfully recognized you as an admin."
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.4%
  • Shell 0.6%