chainlit
chainlit copied to clipboard
cl.oauth_callback can't work
Describe the bug I defined a third-party ssoprovider myself and added the provider using from chainlit.oauth_providers import providers. Jumping to the login page has been implemented. However, when I clicked to log in, my custom oauth_callback() method failed to receive the request, which was automatically sent to chainlit's own oauth_callback(), preventing me from changing the logon logic.
To Reproduce Steps to reproduce the behavior: 1.my provider: `class FooBarProvider(OAuthProvider): id="your-id" env=["YOUR_ENV_VAR_NAMES"]
authorize_url=f"https://get.your/auth_url"
token_url=f"https://get.your/token_url"
def __init__(self):
self.client_id = os.environ.get("YOUR_ENV_VAR_NAMES")
async def get_token(self, code: str, url: str) -> str:
payload = { "foo": self.client_id }
async with httpx.AsyncClient() as client:
response = await client.post(
self.token_url,
data=payload
)`
2.inject_custom_auth.py
...... def add_custom_oauth_provider(provider_id: str, custom_provider_instance): if custom_oauth_enabled() and not provider_id_in_instance_list(provider_id): providers.append(custom_provider_instance) print(f"Added provider: {provider_id}") else: print(f"Custom OAuth is not enabled or provider {provider_id} already exists")
3.injection app.py
`from cookbook.auth.foobar_oauthprovider import FooBarProvider
from cookbook.auth.inject_custom_auth import add_custom_oauth_provider
add_custom_oauth_provider("foobar", FooBarProvider())
@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 `
Expected behavior A clear and concise description of what you expected to happen. oauth_callback() can recive callback and modify logic
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: win11
- Browser chrome
- Version chainlit-main
I'm also having this issue, I thought it was Cognito at first. Apparently is not.
@nestorcolt-clv Yes,Yes, I thought there was something wrong with my program at first, but after checking it, it didn't work. I wonder if there is a way to solve this problem,I need support our SSO(Oauth2) systemctl.
@asd332689912 @nestorcolt-clv Are you still experiencing this issue withe the current chainlit version?