Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cl.oauth_callback can't work #1001

Open
asd332689912 opened this issue May 16, 2024 · 2 comments
Open

cl.oauth_callback can't work #1001

asd332689912 opened this issue May 16, 2024 · 2 comments

Comments

@asd332689912
Copy link

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.
qqqq
1715873091180

Desktop (please complete the following information):

  • OS: win11
  • Browser chrome
  • Version chainlit-main
@nestorcolt-clv
Copy link

I'm also having this issue, I thought it was Cognito at first. Apparently is not.

@asd332689912
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants