flet
flet copied to clipboard
Azure OAuth not working
Duplicate Check
- [X] I have searched the opened issues and there are no duplicates
Describe the bug
I copied the example from the documentation and modified it to make sure it would work with Azure. Then after providing the required IDs and secret, I ran into the following error:
Sorry, but we’re having trouble signing you in.
AADSTS9002325: Proof Key for Code Exchange is required for cross-origin authorization code redemption.
I can create a Flask application and login with it, but it would be nice to have this built-in solution working as well.
Code sample
Here is the code I took and modified from the documentation:
import os
import flet as ft
from flet.auth.providers import AzureOAuthProvider
import utils.config as config
def main(page: ft.Page):
provider = AzureOAuthProvider(
client_id=config.CLIENT_ID,
client_secret=config.CLIENT_SECRET,
redirect_url="http://localhost:8550/oauth_callback",
tenant=config.TENANT_ID,
)
def login_click(e):
page.login(provider)
def on_login(e):
print("Login error:", e.error)
print("Access token:", page.auth.token.access_token)
print("User ID:", page.auth.user.id)
page.on_login = on_login
page.add(ft.ElevatedButton("Login with Azure", on_click=login_click))
ft.app(main, port=8550, view=ft.WEB_BROWSER)
To reproduce
- Create App registration in Azure Portal
- Configure App registration appropriately according to the documentation. (Use the Single-page application option)
- Run the code provided.
- Try to login.
Operating System
Windows
Operating system details
Windows 10
Flet version
0.23.2
Regression
I'm not sure / I don't know
Suggestions
I can suggest taking a look at Microsoft's documentation:
https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-web-app-python-flask?tabs=windows