-
Notifications
You must be signed in to change notification settings - Fork 3
(api definitions) Document OpenAPI OAuth and clarify parameters #1278
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| Configuration for the token acquisition endpoint. | ||
| Specifies the endpoint that exchanges client credentials for an access token. This endpoint is called automatically when the SDK client is initialized. | ||
|
|
||
| ```yaml | ||
| ```yaml title="generators.yml" | ||
| get-token: | ||
| endpoint: "auth.get_token" | ||
| request-properties: | ||
|
|
@@ -12,29 +12,29 @@ get-token: | |
| ``` | ||
|
|
||
| <ParamField path="endpoint" type="string" required={true}> | ||
| The endpoint to get the access token, such as `'auth.get_token'`. | ||
| The endpoint that issues access tokens, such as `'auth.get_token'`. | ||
| </ParamField> | ||
| <ParamField path="request-properties" type="object" required={false}> | ||
| Customizes the property names used in the token request. | ||
| Maps OAuth parameter names to your API's request field names. Use this when your token endpoint expects different field names than the OAuth standard (e.g., your API uses `clientId` instead of `client_id`). | ||
| </ParamField> | ||
| <ParamField path="client-id" type="string" required={false}> | ||
| The property name for the client ID in the request. | ||
| <ParamField path="request-properties.client-id" type="string" required={false}> | ||
| The request field name for the client ID in your API (e.g., `"clientId"`, `"client_id"`). | ||
| </ParamField> | ||
| <ParamField path="client-secret" type="string" required={false}> | ||
| The property name for the client secret in the request. | ||
| <ParamField path="request-properties.client-secret" type="string" required={false}> | ||
| The request field name for the client secret in your API (e.g., `"clientSecret"`, `"client_secret"`). | ||
| </ParamField> | ||
| <ParamField path="scopes" type="string" required={false}> | ||
| The property name for the scopes in the request. | ||
| <ParamField path="request-properties.scopes" type="string" required={false}> | ||
| The request field name for scopes in your API (e.g., `"scope"`, `"scopes"`). | ||
| </ParamField> | ||
| <ParamField path="response-properties" type="object" required={false}> | ||
| Maps custom property names in your OAuth token response (e.g., if your API returns `accessToken` instead of `access_token`). | ||
| Maps your API's response field names to OAuth standard names. Use this when your API returns tokens with different field names (e.g., `accessToken` instead of `access_token`). | ||
| </ParamField> | ||
| <ParamField path="access-token" type="string" required={false}> | ||
| The property name for the access token in the response. | ||
| <ParamField path="response-properties.access-token" type="string" required={false}> | ||
| The response field name for the access token in your API (e.g., `"accessToken"`, `"access_token"`). | ||
| </ParamField> | ||
| <ParamField path="expires-in" type="string" required={false}> | ||
| The property name for the expires in property in the response. | ||
| <ParamField path="response-properties.expires-in" type="string" required={false}> | ||
| The response field name for token expiration time in seconds (e.g., `"expiresIn"`, `"expires_in"`). When present, the SDK automatically refreshes tokens before expiration. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </ParamField> | ||
| <ParamField path="refresh-token" type="string" required={false}> | ||
| The property name for the refresh token in the response. | ||
| The response field name for the refresh token in your API (e.g., `"refreshToken"`, `"refresh_token"`). Required if using the `refresh-token` flow. | ||
| </ParamField> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| Configure OAuth 2.0 client credentials authentication. | ||
| <Note> | ||
| For Fern Definition, you can configure OAuth authentication either in `generators.yml` or [directly in your `api.yml` file](/api-definitions/ferndef/authentication#oauth-client-credentials). For OpenAPI, [OAuth must be configured in `generators.yml`](/api-definitions/openapi/authentication#oauth-client-credentials). | ||
| </Note> | ||
|
|
||
| ```yaml | ||
| Configure OAuth 2.0 client credentials authentication. Optionally configure a `refresh-token` endpoint for token renewal without re-authentication. | ||
|
|
||
| ```yaml title="generators.yml" maxLines=10 | ||
| auth-schemes: | ||
| my-oauth: # User-defined scheme name | ||
| scheme: oauth | ||
|
|
@@ -31,15 +35,14 @@ auth-schemes: | |
| expires-in: "expires_in" | ||
| refresh-token: "refresh_token" | ||
| ``` | ||
|
|
||
| <ParamField path="scheme" type="'oauth'" required={true}> | ||
| Must be set to `"oauth"` for OAuth authentication schemes. | ||
| </ParamField> | ||
| <ParamField path="type" type="literal<'client-credentials'>" required={true}> | ||
| The OAuth flow type. Currently only `"client-credentials"` is supported. | ||
| <ParamField path="type" type="'client-credentials'" required={true}> | ||
| The OAuth 2.0 grant type. Currently only `"client-credentials"` is supported. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </ParamField> | ||
| <ParamField path="scopes" type="list<string>" required={false}> | ||
| List of OAuth scopes to request during authentication. | ||
| <ParamField path="scopes" type="list of strings" required={false}> | ||
| OAuth scopes to request when obtaining access tokens (e.g., `"read:users"`, `"write:orders"`). | ||
| </ParamField> | ||
| <ParamField path="client-id-env" type="string" required={false}> | ||
| Environment variable name containing the OAuth client ID. When specified, the generated SDK will automatically scan for this environment variable at initialization. | ||
|
|
@@ -48,8 +51,8 @@ auth-schemes: | |
| Environment variable name containing the OAuth client secret. When specified, the generated SDK will automatically scan for this environment variable at initialization. | ||
| </ParamField> | ||
| <ParamField path="token-prefix" type="string" default="Bearer"> | ||
| Sets the token header value prefix. | ||
| Prefix added to the access token in the Authorization header (e.g., `"Bearer"` results in `"Authorization: Bearer <token>"`). Useful when your API expects a custom format. | ||
| </ParamField> | ||
| <ParamField path="token-header" type="string" default="Authorization"> | ||
| Sets the token header key name. | ||
| HTTP header name used to send the access token. Defaults to `"Authorization"` but can be customized if your API uses a different header (e.g., `"X-API-Token"`). | ||
| </ParamField> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| Configuration for the token refresh endpoint. | ||
| Specifies the endpoint that exchanges a refresh token for a new access token. When configured, the SDK automatically uses this endpoint to renew expired tokens without re-sending credentials. If not configured, the SDK will re-authenticate using `get-token` when tokens expire. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| ```yaml | ||
| ```yaml title="generators.yml" | ||
| refresh-token: | ||
| endpoint: "auth.refresh_token" | ||
| request-properties: | ||
|
|
@@ -11,23 +11,23 @@ refresh-token: | |
| ``` | ||
|
|
||
| <ParamField path="endpoint" type="string" required={true}> | ||
| The endpoint to refresh the access token, such as `'auth.refresh_token'`. | ||
| The endpoint that refreshes access tokens (e.g., `"POST /oauth/refresh"` or `"auth.refreshToken"`). | ||
| </ParamField> | ||
| <ParamField path="request-properties" type="object" required={false}> | ||
| Maps custom property names in your refresh token request. | ||
| Maps OAuth parameter names to your API's request field names for the refresh flow. | ||
| </ParamField> | ||
| <ParamField path="refresh-token" type="string" required={true}> | ||
| The property name for the refresh token in the request. | ||
| <ParamField path="request-properties.refresh-token" type="string" required={true}> | ||
| The request field name for the refresh token in your API (e.g., `"refreshToken"`, `"refresh_token"`). | ||
| </ParamField> | ||
| <ParamField path="response-properties" type="object" required={false}> | ||
| Maps custom property names in your refresh token response. | ||
| Maps your API's refresh response field names to OAuth standard names. | ||
| </ParamField> | ||
| <ParamField path="access-token" type="string" required={false}> | ||
| The property name for the access token in the response. | ||
| <ParamField path="response-properties.access-token" type="string" required={false}> | ||
| The response field name for the new access token (e.g., `"accessToken"`, `"access_token"`). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </ParamField> | ||
| <ParamField path="expires-in" type="string" required={false}> | ||
| The property name for the expires in property in the response. | ||
| <ParamField path="response-properties.expires-in" type="string" required={false}> | ||
| The response field name for the new token's expiration time in seconds (e.g., `"expiresIn"`, `"expires_in"`). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </ParamField> | ||
| <ParamField path="refresh-token" type="string" required={false}> | ||
| The property name for the refresh token in the response. | ||
| <ParamField path="response-properties.refresh-token" type="string" required={false}> | ||
| The response field name if your API issues a new refresh token with each refresh (token rotation). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </ParamField> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Headings] 'OAuth client credentials' should use sentence-style capitalization.