> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OAuth-Authorization-Codes-Collection

`oauthAuthorizationCodes` ist für die Codes des OAuth-Authorization-Code-Flows gedacht: ein Dokument pro Code, den ein Client gegen ein Zugriffstoken eintauscht. Das Schema ist `services/web/app/src/models/OauthAuthorizationCode.mjs`, und das Web-Modul `oauth2-server` enthält den Code, der hineinschreiben würde. In Ayakaleaf Pro erreicht nichts diesen Code, daher bleibt die Collection leer (siehe Hinweise).

#### Felder

| Feld | Typ | Bedeutung | Quelle |
| - | - | - | - |
| `_id` | ObjectId | Dokument-ID. | `OauthAuthorizationCode.mjs:6` |
| `authorizationCode` | String | Der Code selbst, unverändert gespeichert (nicht gehasht). | `OauthAuthorizationCode.mjs:8`, `services/web/modules/oauth2-server/app/src/OAuth2Model.mjs:280` |
| `expiresAt` | Date | Ende der Gültigkeit. `getAuthorizationCode` lehnt einen Code danach ab, und der TTL-Index löscht ihn. | `OauthAuthorizationCode.mjs:9`, `OAuth2Model.mjs:150-153,281` |
| `oauthApplication_id` | ObjectId | Client in [OAuth Applications](https://ayakaleaf-pro.mintlify.site/de/dev/data-model/oauth-applications-collection.md), der den Code angefordert hat. | `OauthAuthorizationCode.mjs:10`, `OAuth2Model.mjs:275-284` |
| `redirectUri` | String | Redirect-URI der Anfrage. | `OauthAuthorizationCode.mjs:11`, `OAuth2Model.mjs:282` |
| `scope` | String | Angeforderter Scope. | `OauthAuthorizationCode.mjs:12`, `OAuth2Model.mjs:283` |
| `user_id` | ObjectId | Benutzer, der den Code gewährt hat. | `OauthAuthorizationCode.mjs:13`, `OAuth2Model.mjs:285` |
| `codeChallenge`, `codeChallengeMethod` | String | PKCE-Challenge und ihre Methode. | `OauthAuthorizationCode.mjs:14-15`, `OAuth2Model.mjs:286-287` |

#### Wer schreibt

| Code | Funktion |
| - | - |
| `OAuth2Model.mjs:274-300` (`saveAuthorizationCode`) | Fügt einen Code ein. Wird nicht erreicht, siehe Hinweise. |
| `OAuth2Model.mjs:307-312` (`revokeAuthorizationCode`) | Löscht einen Code, sobald er verwendet wurde. Wird nicht erreicht. |

#### Wer liest

| Code | Funktion |
| - | - |
| `OAuth2Model.mjs:137-177` (`getAuthorizationCode`) | Lädt einen Code mit seinem Benutzer und Client. Wird nicht erreicht. |

#### Indizes

| Name | Schlüssel | Optionen | Migration |
| - | - | - | - |
| `expiresAt_1` | `{ expiresAt: 1 }` | TTL, `expireAfterSeconds: 0`, partiell: `expiresAt` existiert | `20230406125632_oauth_tokens_ttl.mjs` |

Die Migrationen liegen in `tools/migrations/`. Der eindeutige Index `authorizationCode_1` stammt nur aus Migrationen mit den Tags `saas` und `server-pro`, die die Community Edition nicht ausführt.

#### Hinweise

* Die obigen Modellmethoden werden nur von den Authorize- und Token-Handlern von `@node-oauth/oauth2-server` aufgerufen. Web nutzt diese Bibliothek nur zum Prüfen von Bearer-Token (`services/web/app/src/Features/Authentication/AuthenticationController.mjs:409-450`), und keine Route bedient `/oauth/authorize` oder `/oauth/token`. Daher wird nie ein Code geschrieben. Persönliche Zugriffstoken werden direkt erstellt, siehe [OAuth Access Tokens](https://ayakaleaf-pro.mintlify.site/de/dev/data-model/oauth-access-tokens-collection.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.