-
Notifications
You must be signed in to change notification settings - Fork 2
chore(other): update docs with refresh token grant type #20
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
71a1f38
chore(other): update docs with refresh token grant type
DmitryAnansky 1667e9f
chore(other): changes after review
DmitryAnansky 5a17930
chore(other): changes after review
DmitryAnansky 46ab4e2
chore(other): changes after review
DmitryAnansky e7bad1b
chore(other): update docs
DmitryAnansky ed19299
chore(other): document revoke endpoint
DmitryAnansky 115816d
chore: revert revoke endpoint documentation
DmitryAnansky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -48,11 +48,27 @@ components: | |
| securitySchemes: | ||
| OAuth2: | ||
| type: oauth2 | ||
| description: OAuth2 authorization for API access. | ||
| description: | | ||
| OAuth2 authorization for API access. The token endpoint accepts `grant_type=authorization_code`, `grant_type=client_credentials`, and `grant_type=refresh_token`. | ||
|
|
||
| ### Differences from the OAuth2 specifications | ||
|
|
||
| A standard OAuth2 client library can drive these flows, with the following to account for. | ||
|
|
||
| Two behaviors do not conform to the specifications: | ||
|
|
||
| - **Errors use RFC 9457 problem+json, not RFC 6749 Section 5.2.** Failures return `application/problem+json` with `type`, `title`, `status`, and `instance`. There is no `error` or `error_description` field, so the standard codes (`invalid_grant`, `invalid_client`, `unsupported_grant_type`) never appear — branch on the HTTP status and `title` instead. A refresh token that is expired, already rotated, or unrecognized returns `400` with a `title` of `Refresh token has expired` or `Invalid refresh token`, where a conformant server would return `error: invalid_grant`. | ||
|
DmitryAnansky marked this conversation as resolved.
|
||
| - **`refresh_token` is not a registrable grant type.** RFC 7591 Section 2 lists it, but `/oauth2/register` accepts only `authorization_code` and `client_credentials` in `grantTypes`. Refreshing requires no registration: holding a refresh token issued to the client is the authorization. A consequence is that refresh capability cannot be disabled per client — every `authorization_code` grant returns a refresh token, so a client intended for a shared or public device cannot be registered without one. | ||
|
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. |
||
|
|
||
| Two are choices the specifications leave to the server: | ||
|
|
||
| - **Refresh tokens rotate on every use.** A successful refresh retires the token presented and returns a replacement in `refresh_token`, as RFC 6749 Section 6 permits and the OAuth2 Security Best Current Practice recommends. Store the new value; the old one stops working. Refresh tokens expire 30 days after they are issued, and rotation restarts that window. The authorization code flow returns a refresh token with every access token; the client credentials flow returns none (RFC 6749 Section 4.4.3). | ||
|
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. |
||
| - **`scope` accepts commas.** The space-delimited form required by RFC 6749 is always accepted and recommended; comma-separated values are additionally tolerated. | ||
|
DmitryAnansky marked this conversation as resolved.
|
||
| flows: | ||
| authorizationCode: | ||
| authorizationUrl: https://api.cafe.redocly.com/oauth2/authorize | ||
| tokenUrl: https://api.cafe.redocly.com/oauth2/token | ||
| refreshUrl: https://api.cafe.redocly.com/oauth2/token | ||
| scopes: | ||
| menu:read: Read access to menu items and images | ||
| menu:write: Write access to menu items (create, delete) | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Deviating from the standard OAuth2 error format (
error,error_description) in favor of RFC 9457 breaks compatibility with standard OAuth2 client libraries, potentially causing client-side failures or improper error handling in integrated applications.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.
I will review it in other pr and align API codebase with documentation.