.. index:: single: http_oauth_metadata
.. _http_oauth_metadata/0:

.. rst-class:: right

**object**

``http_oauth_metadata``
=======================

OAuth protected-resource metadata document and HTTP response builder following RFC 9728.

| **Availability:** 
|    ``logtalk_load(http_oauth(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-09-01

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`options <options/0>`
| **Uses:**
|    :ref:`http_core <http_core/0>`
|    :ref:`list <list/0>`
|    :ref:`type <type/0>`
|    :ref:`url(Representation) <url/1>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: well_known_url/2
.. _http_oauth_metadata/0::well_known_url/2:

``well_known_url/2``
^^^^^^^^^^^^^^^^^^^^

Returns the RFC 9728 well-known metadata URL for a canonical protected-resource identifier.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``well_known_url(ProtectedResource,URL)``
| **Mode and number of proofs:**
|    ``well_known_url(+atom,-atom)`` - ``one_or_error``

| **Exceptions:**
|    ``ProtectedResource`` is not a canonical HTTPS protected-resource identifier:
|        ``domain_error(http_oauth_protected_resource,ProtectedResource)``


------------

.. index:: document/3
.. _http_oauth_metadata/0::document/3:

``document/3``
^^^^^^^^^^^^^^

Builds a protected-resource metadata JSON object from descriptor terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``document(ProtectedResource,Descriptors,Document)``
| **Mode and number of proofs:**
|    ``document(+atom,+list(compound),-term)`` - ``one_or_error``

| **Exceptions:**
|    ``ProtectedResource`` is not a canonical HTTPS protected-resource identifier:
|        ``domain_error(http_oauth_protected_resource,ProtectedResource)``
|    ``Descriptors`` is not a proper list:
|        ``type_error(list,Descriptors)``
|    An element ``Descriptor`` of the list ``Descriptors`` is not a valid metadata descriptor:
|        ``domain_error(http_oauth_metadata_descriptor,Descriptor)``
|    ``Descriptors`` contains duplicate metadata members:
|        ``domain_error(http_oauth_metadata_descriptors,Descriptors)``


------------

.. index:: document/4
.. _http_oauth_metadata/0::document/4:

``document/4``
^^^^^^^^^^^^^^

Builds a protected-resource metadata JSON object subject to profile options.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``document(ProtectedResource,Descriptors,Document,Options)``
| **Mode and number of proofs:**
|    ``document(+atom,+list(compound),-term,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``ProtectedResource`` is not a canonical HTTPS protected-resource identifier:
|        ``domain_error(http_oauth_protected_resource,ProtectedResource)``
|    ``Descriptors`` is not a proper list:
|        ``type_error(list,Descriptors)``
|    An element ``Descriptor`` of the list ``Descriptors`` is not a valid metadata descriptor:
|        ``domain_error(http_oauth_metadata_descriptor,Descriptor)``
|    ``Descriptors`` contains duplicate metadata members:
|        ``domain_error(http_oauth_metadata_descriptors,Descriptors)``
|    ``Options`` is a variable:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    An element ``Option`` of the list ``Options`` is a variable:
|        ``instantiation_error``
|    An element ``Option`` of the list ``Options`` is neither a variable nor a compound term:
|        ``type_error(compound,Option)``
|    An element ``Option`` of the list ``Options`` is a compound term but not a valid option:
|        ``domain_error(option,Option)``
|    ``Descriptors`` omits a required metadata member or gives it an empty value:
|        ``domain_error(http_oauth_metadata_descriptors,Descriptors)``


------------

.. index:: response/3
.. _http_oauth_metadata/0::response/3:

``response/3``
^^^^^^^^^^^^^^

Builds a normalized HTTP 200 response containing protected-resource metadata.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``response(ProtectedResource,Descriptors,Response)``
| **Mode and number of proofs:**
|    ``response(+atom,+list(compound),-compound)`` - ``one_or_error``

| **Exceptions:**
|    ``ProtectedResource`` is not a canonical HTTPS protected-resource identifier:
|        ``domain_error(http_oauth_protected_resource,ProtectedResource)``
|    ``Descriptors`` is not a proper list:
|        ``type_error(list,Descriptors)``
|    An element ``Descriptor`` of the list ``Descriptors`` is not a valid metadata descriptor:
|        ``domain_error(http_oauth_metadata_descriptor,Descriptor)``
|    ``Descriptors`` contains duplicate metadata members:
|        ``domain_error(http_oauth_metadata_descriptors,Descriptors)``


------------

.. index:: response/4
.. _http_oauth_metadata/0::response/4:

``response/4``
^^^^^^^^^^^^^^

Builds a normalized HTTP 200 metadata response subject to profile options.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``response(ProtectedResource,Descriptors,Response,Options)``
| **Mode and number of proofs:**
|    ``response(+atom,+list(compound),-compound,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``ProtectedResource`` is not a canonical HTTPS protected-resource identifier:
|        ``domain_error(http_oauth_protected_resource,ProtectedResource)``
|    ``Descriptors`` is not a proper list:
|        ``type_error(list,Descriptors)``
|    An element ``Descriptor`` of the list ``Descriptors`` is not a valid metadata descriptor:
|        ``domain_error(http_oauth_metadata_descriptor,Descriptor)``
|    ``Descriptors`` contains duplicate metadata members:
|        ``domain_error(http_oauth_metadata_descriptors,Descriptors)``
|    ``Options`` is a variable:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    An element ``Option`` of the list ``Options`` is a variable:
|        ``instantiation_error``
|    An element ``Option`` of the list ``Options`` is neither a variable nor a compound term:
|        ``type_error(compound,Option)``
|    An element ``Option`` of the list ``Options`` is a compound term but not a valid option:
|        ``domain_error(option,Option)``
|    ``Descriptors`` omits a required metadata member or gives it an empty value:
|        ``domain_error(http_oauth_metadata_descriptors,Descriptors)``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

