Friday, October 9, 2026

oauth2 et py4web

 pour activer l'authent avec google.

partir de _scaffold

1/ dans settings.py

 
  OAUTH2GOOGLE_CLIENT_ID = '58406607345-.......
  OAUTH2GOOGLE_CLIENT_SECRET = 'GOCSPX..........
  
2/ dans common.py

adapter le plugin 

 
if settings.OAUTH2GOOGLE_CLIENT_ID:
    from py4web.utils.auth_plugins.oauth2google import OAuth2Google

    class CustomOAuth2Google(OAuth2Google):
        def get_login_url(self):
            # Récupère l'URL chaîne de caractères construite par py4web
            url = super().get_login_url()
            # Ajoute le paramètre �|  la fin de la query string
            return url + "&prompt=select_account"

    auth.register_plugin(
        CustomOAuth2Google(
            client_id=settings.OAUTH2GOOGLE_CLIENT_ID,
            client_secret=settings.OAUTH2GOOGLE_CLIENT_SECRET,
            callback_url="auth/plugin/oauth2google/callback",
        )
    )
3/ sur google

https://console.cloud.google.com/apis/credentials?project=py4web-375721

ajouter l'URI de redirection  dans "myclientapp"

4/ pas besoin de créer le user à l'avance.

No comments:

Post a Comment

model routing

 https://towardsdatascience.com/the-hidden-cost-of-llm-routing-why-switching-models-costs-more/?utm_campaign=tds%20daily&utm_medium=emai...