Auth0 Client Credential Flow for API Authentication

I was working on adding some security to my API’s and wanted to use the client credential grant flow for machine to machine communication.

I tweak auth0’s example and made it work in an anvil application :slight_smile:

Here is the auth0 documentation:

Requesting a token

Client Credential Flow

Python Example

I pieced together some things to get the job done without flask.

Here is the clone:


I am using the BETA capabilities to install your own libraries on python 3.10, but the libraries you need are python-jose and six which are already installed in the standard production anvil server!

Example usage:

from .utils import requires_auth

def test_auth():  
  return {"test-string":"It was successful!"}

Where requires_auth is a wrapper that authenticates auth0 Bearer tokens!

All you have to update are the application secrets:



the clone link is busted .

I’ll try to update the link, but it seems as though I can’t open the IDE, so that could be the issue. I’ll update when that resolves.


I believe it has to do this post:

Not the clone link itself.