0

My code:

import os

import flet as ft
from flet.auth.providers.google_oauth_provider import GoogleOAuthProvider

def main(page: ft.Page):

    provider = GoogleOAuthProvider(
        client_id=**CLIENT_ID**,
        client_secret=**CLIENT_SECRET**,
        redirect_url="http://localhost:8550/api/oauth/redirect",
    )

    def login_click(e):
        page.login(provider)

    def on_login(e):
        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 GitHub", on_click=login_click))

ft.app(target=main, port=8550, view=ft.WEB_BROWSER)

When I run the above in the terminal using Python file.py, a browser open's up and the authentication works. But when I try flet run file.py, a web browser does open up and gives me the option to sign in, but it does not seem to work on redirect. Can someone please help me with this. Thank you.

0 Answers0