# Type Alias: OAuth2Authentication

> **OAuth2Authentication** = [`OAuth2StaticCodeAuthentication`](../../interfaces/OAuth2StaticCodeAuthentication/) | [`OAuth2DynamicCodeAuthentication`](../../interfaces/OAuth2DynamicCodeAuthentication/)

Defined in: [types.ts:658](https://github.com/coda/packs-sdk/blob/9f37f0e6dd85972eb9c035c2bb489cbeb06120bc/types.ts#L658)

Authenticate using the OAuth2 Authorization Code flow. You must specify the authorization URL, token exchange URL, and scopes here as part of the pack definition. You'll provide the application's client ID and client secret in the pack management UI, so that these can be stored securely.

The API must use a (largely) standards-compliant implementation of OAuth2.

When `useDynamicClientRegistration` is `true`, `authorizationUrl` and `tokenUrl` become optional as they are automatically discovered using the pack's declared MCP servers and network domains.

## See

- [Authenticating using OAuth](https://coda.io/packs/build/latest/guides/basics/authentication/oauth2/)
- [Authentication samples - OAuth2](https://coda.io/packs/build/latest/samples/topic/authentication/#oauth2)
