-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathscopes_auth0.py
More file actions
39 lines (32 loc) · 1.24 KB
/
scopes_auth0.py
File metadata and controls
39 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
This example shows how to configure an OpenID Connect integration with Auth0, obtaining
an id_token, an access_token, and a refresh_token. The id_token is exchanged with the
client using a response cookie (also used to authenticate users
for following requests), while access token and the refresh token are not stored and
can only be accessed using optional events.
"""
import uvicorn
from blacksheep.server.application import Application
from blacksheep.server.authentication.oidc import OpenIDSettings, use_openid_connect
from dotenv import load_dotenv
from common.routes import register_routes
from common.secrets import Secrets
load_dotenv()
secrets = Secrets.from_env()
app = Application(show_error_details=True)
# Auth0 with custom scope
use_openid_connect(
app,
OpenIDSettings(
authority="https://neoteroi.eu.auth0.com",
audience="http://localhost:5000/api/todos",
client_id="OOGPl4dgG7qKsm2IOWq72QhXV4wsLhbQ",
client_secret=secrets.auth0_client_secret,
callback_path="/signin-oidc",
scope="openid profile read:todos",
error_redirect_path="/sign-in-error",
),
)
register_routes(app)
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=5000, log_level="debug")