Skip to content

Commit 7f724e1

Browse files
Update oauth.mdx adding instruction on how to add custom OAuth provider (#216)
* Update oauth.mdx adding instruction on how to add custom OAuth provider Closes #214 * Update oauth.mdx --------- Co-authored-by: Willy Douhard <[email protected]>
1 parent 2f91b00 commit 7f724e1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

authentication/oauth.mdx

+14
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ You need to set the following environment variables:
147147
- `OAUTH_KEYCLOAK_BASE_URL`: Your Keycloak URL.
148148
- `OAUTH_KEYCLOAK_NAME`: Optional, see above.
149149

150+
### Custom Provider
151+
It's possible to plug-in for any OAuth provider using Chainlit. Required steps are:
152+
- modifying `providers` variable in runtime
153+
- implementing `CustomOAuthProvider(OAuthProvider)` class with methods and fields:
154+
- `get_token(self, code, url)`
155+
- `get_user_info(self, token)`
156+
- `authorize_params`
157+
- `env`
158+
- providing environmental variables as described in `env`, for example:
159+
- `YOUR_PROVIDER_CLIENT_ID`
160+
- `YOUR_PROVIDER_CLIENT_SECRET`
161+
162+
[This cookbook example](https://github.com/Chainlit/cookbook/tree/main/auth) describes how to do it, also check [base class](https://github.com/Chainlit/chainlit/blob/2cb38ad8596ac547355f87266bc15ab3dfd632d2/backend/chainlit/oauth_providers.py#L13) for reference.
163+
150164
## Prompt Configuration
151165

152166
Starting from version 1.3.0, Chainlit allows you to configure how OAuth providers handle re-authentication through the `prompt` parameter. This is particularly useful for controlling the login behavior when users log out.

0 commit comments

Comments
 (0)