.. index:: single: open_id_client
.. _open_id_client/0:

.. rst-class:: right

**object**

``open_id_client``
==================

HTTP-facing OpenID Connect client predicates.

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

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

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


| **Imports:**
|    ``public`` :ref:`open_id_helpers <open_id_helpers/0>`
| **Uses:**
|    :ref:`base64 <base64/0>`
|    :ref:`http_client <http_client/0>`
|    :ref:`http_core <http_core/0>`
|    :ref:`list <list/0>`
|    :ref:`open_id_discovery <open_id_discovery/0>`
|    :ref:`user <user/0>`

| **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:: discover/3
.. _open_id_client/0::discover/3:

``discover/3``
^^^^^^^^^^^^^^

Discovers and validates OpenID Provider metadata for the given issuer.

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

| **Template:**
|    ``discover(Issuer,Provider,Options)``
| **Mode and number of proofs:**
|    ``discover(+atom,-compound,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    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)``
|    ``Issuer`` is a variable:
|        ``instantiation_error``
|    ``Issuer`` is not an absolute or allowed issuer URL:
|        ``domain_error(open_id_issuer,Issuer)``
|    The discovery endpoint returned a non-success status:
|        ``domain_error(open_id_http_status,Code)``
|    The discovery endpoint response body is not JSON:
|        ``domain_error(open_id_json_response,Body)``
|    The discovered issuer does not match ``Issuer``:
|        ``domain_error(open_id_issuer,DiscoveredIssuer)``
|    A provider metadata URL is not secure:
|        ``domain_error(open_id_provider_metadata_url,URL)``


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

.. index:: jwks/3
.. _open_id_client/0::jwks/3:

``jwks/3``
^^^^^^^^^^

Fetches the JSON Web Key Set for the given provider metadata.

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

| **Template:**
|    ``jwks(Provider,JWKSet,Options)``
| **Mode and number of proofs:**
|    ``jwks(+compound,-term,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    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)``
|    The JWKS endpoint returned a non-success status:
|        ``domain_error(open_id_http_status,Code)``
|    The JWKS endpoint response body is not JSON:
|        ``domain_error(open_id_json_response,Body)``


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

.. index:: exchange_code/5
.. _open_id_client/0::exchange_code/5:

``exchange_code/5``
^^^^^^^^^^^^^^^^^^^

Exchanges an authorization code for token response data.

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

| **Template:**
|    ``exchange_code(Provider,Code,Session,Tokens,Options)``
| **Mode and number of proofs:**
|    ``exchange_code(+compound,+atom,+compound,-compound,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    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)``
|    ``Session`` is missing required authorization-code exchange data:
|        ``domain_error(open_id_session,missing(Session,Name))``
|    The token endpoint returned a non-success status:
|        ``domain_error(open_id_http_status,Code)``
|    The token endpoint response body is not JSON:
|        ``domain_error(open_id_json_response,Body)``
|    The token endpoint JSON response is missing a required member:
|        ``domain_error(open_id_token_response,missing(Name))``


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

.. index:: refresh_token/4
.. _open_id_client/0::refresh_token/4:

``refresh_token/4``
^^^^^^^^^^^^^^^^^^^

Exchanges a refresh token for token response data.

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

| **Template:**
|    ``refresh_token(Provider,RefreshToken,Tokens,Options)``
| **Mode and number of proofs:**
|    ``refresh_token(+compound,+atom,-compound,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    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)``
|    The ``client_id`` option is missing:
|        ``domain_error(open_id_refresh_token,missing(client_id))``
|    The token endpoint returned a non-success status:
|        ``domain_error(open_id_http_status,Code)``
|    The token endpoint response body is not JSON:
|        ``domain_error(open_id_json_response,Body)``
|    The token endpoint JSON response is missing a required member:
|        ``domain_error(open_id_token_response,missing(Name))``


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

.. index:: userinfo/4
.. _open_id_client/0::userinfo/4:

``userinfo/4``
^^^^^^^^^^^^^^

Fetches UserInfo claims using the given access token.

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

| **Template:**
|    ``userinfo(Provider,AccessToken,Claims,Options)``
| **Mode and number of proofs:**
|    ``userinfo(+compound,+atom,-term,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    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)``
|    The provider metadata is missing a UserInfo endpoint:
|        ``domain_error(open_id_provider,missing(userinfo_endpoint))``
|    The UserInfo endpoint returned a non-success status:
|        ``domain_error(open_id_http_status,Code)``
|    The UserInfo endpoint response body is not JSON:
|        ``domain_error(open_id_json_response,Body)``


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

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

(no local declarations; see entity ancestors if any)

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

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

