-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
97 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: OAuth | ||
excerpt: Fern supports OAuth as a first class citizen | ||
--- | ||
|
||
<Warning title='Pro Feature'> | ||
This feature is only available on paid plans. Please schedule a [demo](https://buildwithfern.com/contact) | ||
or [email us](mailto:[email protected]) to get started. | ||
</Warning> | ||
|
||
Fern supports the OAuth 2.0 authorization framework as a first class citizen. With Fern, users don't need | ||
to retrieve and manage access tokens manually. Instead, Fern SDKs will handle the entire OAuth flow. | ||
|
||
For the `client-credentials` OAuth flow, the user simply provides their `client-id` and `client-secret`, | ||
and they're ready to go. | ||
|
||
<Tabs> | ||
<Tab title="TypeScript"> | ||
|
||
When OAuth is configured, the TypeScript SDK's client constructor will include the `clientId` and | ||
`clientSecret` parameters. | ||
|
||
Constructing the client is as simple as: | ||
```typescript Client.ts | ||
client = new Client({ | ||
clientId: 'YOUR_CLIENT_ID', | ||
clientSecret: 'YOUR_CLIENT_SECRET', | ||
}); | ||
``` | ||
|
||
Behind the scenes, the `core.OAuthTokenProvider` retrieves an access token and refreshes it as needed. With this, | ||
the rest of the API (like the `User` client) can use the token to authenticate every request. | ||
|
||
</Tab> | ||
|
||
<Tab title="Python"> | ||
|
||
When OAuth is configured, the Python SDK's client constructor will include the `client_id` and | ||
`client_secret` parameters. | ||
|
||
Constructing the client is as simple as: | ||
```python client.py | ||
client = Client( | ||
client_id="YOUR_CLIENT_ID", | ||
client_secret="YOUR_CLIENT_SECRET", | ||
) | ||
``` | ||
|
||
Behind the scenes, the `core.OAuthTokenProvider` retrieves an access token and refreshes it as needed. With this, | ||
the rest of the API (like the `UserClient`) can use the token to authenticate every request. | ||
|
||
</Tab> | ||
</Tabs> | ||
|
||
### Supported Authorization Flows | ||
|
||
Fern supports the following OAuth authorization flows: | ||
|
||
| Authorization Flow | Supported | Example | | ||
|--------------------|--------------------------------------------------|--------------------------------------------------------------| | ||
| client-credentials | <Icon icon="check" color="#84B060" /> | [Sayari](https://github.com/sayari-analytics/sayari-python) | | ||
| authorization-code | <Icon icon="check" color="#84B060" /> | [Webflow](https://github.com/webflow/webflow-python) | | ||
| pkce | | | |