Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions authentication/oauth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OAuth lets you use third-party services to authenticate your users.

<Note>
To active an OAuth provider, you need to define both the OAuth callback in
your code and the provider(s) environment variables.
your code (`cl.oauth_callback`) and the provider(s) environment variables.
</Note>

## Providers
Expand Down Expand Up @@ -197,7 +197,7 @@ This feature is particularly useful when you want to:

The prompt parameter is defined in the OpenID Connect Core 1.0 specification. For more technical details, refer to the [OpenID Connect documentation](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).

## Examples
## OAuth Callback

### Allow all users who passed the oauth authentication.

Expand All @@ -207,11 +207,12 @@ import chainlit as cl


@cl.oauth_callback
def oauth_callback(
async def oauth_callback(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@divieira this doesn't have to be async like the other decorated functions.

provider_id: str,
token: str,
raw_user_data: Dict[str, str],
default_user: cl.User,
profile: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@divieira which provider has this? I know azure hybrid has the following can you add that too?

id_token: Optional[str],

) -> Optional[cl.User]:
return default_user
```
Expand All @@ -224,11 +225,12 @@ import chainlit as cl


@cl.oauth_callback
def oauth_callback(
async def oauth_callback(
provider_id: str,
token: str,
raw_user_data: Dict[str, str],
default_user: cl.User,
profile : Optional[str] = None
) -> Optional[cl.User]:
if provider_id == "google":
if raw_user_data["hd"] == "example.org":
Expand Down