Closed VasuMavaniT closed 8 months ago
This looks kinda ok, did you configure your environment variables like google client id and secret id as described in the docs?
- So, I have added these 2 variables inside system environment variables: OAUTH_GOOGLE_CLIENT_ID and OAUTH_GOOGLE_CLIENT_SECRET
- And in chainlit application, I have only this file App.py:
import chainlit as cl import pandas as pd import json import time from typing import Optional, Dict
@cl.oauth_callback def oauth_callback( provider_id: str, token: str, raw_user_data: Dict[str, str], default_user: cl.User, ) -> Optional[cl.User]: return default_user
@cl.on_chat_start async def on_chat_start(): app_user = cl.user_session.get("user") await cl.Message(f"Hello {app_user.identifier}").send() await cl.Message("Welcome to the USA Spending Bot!").send()
**And I am running the app using the command: chainlit run app.py --port 8004 -w
I am getting this error currently:**
File "C:\Users\vasu\Documents\Chainlit APFS Site\Entrypoint error resolver\Chainlit Authentication.\app.py", line
12, in
KeyError: 'User'
**I wanted to know what extra file or function is needed to be included for authentication.**
I think you need to update Chainlit. cl.User
is introduced in Chainlit >= 1.0.0
Thank you, @willydouhard After updating the version of chainlit to the latest version, it is working for me.
I want to add google authentication to my chainlit app. For that I have set the environment variables: OAUTH_GOOGLE_CLIENT_ID and OAUTH_GOOGLE_CLIENT_SECRET. What changes should be made in chainlit application below?
import chainlit as cl import pandas as pd import json import time from typing import Optional, Dict
@cl.oauth_callback def oauth_callback( provider_id: str, token: str, raw_user_data: Dict[str, str], default_user: cl.User, ) -> Optional[cl.User]: if provider_id == "google": if raw_user_data["hd"] == "google.com": return default_user return default_user return None
@cl.on_chat_start async def on_chat_start(): app_user = cl.user_session.get("user") await cl.Message(f"Hello {app_user.identifier}").send() await cl.Message("Welcome to the USA Spending Bot!").send()