# mod\_oauth2

Source: https://zotonic.com/docs/1831/mod_oauth2

URI: https://zotonic.com/id/1831

Language: en



OAuth2 provider module for app/client/token management and authorization flows.

Accepted Events
---------------

This module handles the following notifier callbacks:

- `observe_admin_menu`: Add OAuth2 administration entries to the admin menu.
- `observe_request_context`: Check if there is a valid Authorization header or 'access\_token' argument using `z_context:get`.
- `observe_search_query`: Queries to find OAuth2 tokens using `z_datetime:next_hour`.
- `observe_tick_24h`: Periodically delete expired server side tokens using `m_oauth2:delete_expired_tokens`.
- `observe_tick_3h`: Periodically try to extend tokens that are expiring in the next 8 hours using `z_datetime:next_hour`.
- `observe_url_fetch_options`: Check if the current user has a token for the given host using `z_acl:user`.

Delegate callbacks:

- `event/2` with `postback` messages: `oauth2_app_delete`, `oauth2_app_token_delete`, `oauth2_app_token_generate`, `oauth2_consumer_delete`, `oauth2_consumer_token_delete`, `oauth2_fetch_consumer_token`.
- `event/2` with `submit` messages: `oauth2_app_insert`, `oauth2_app_token_new`, `oauth2_app_update`, `oauth2_authorize`, `oauth2_consumer_insert`, `oauth2_consumer_token_new`, `oauth2_consumer_update`.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1831?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1831?language=en>)
