get_well_known_url (rfc9728/well_known.py)

authlib · authlib/oauth2/rfc9728/well_known.py · python · BSD-3-Clause
auth

Builds OAuth 2.0 Protected Resource metadata URLs for API discovery

# Source: https://github.com/authlib/authlib | License: BSD-3-Clause | Copyright 2017, Hsiaoming Yang
# Provided via justclaw.it.com; keep this notice with the code.
"""Support for OAuth 2.0 Protected Resource Metadata .well-known url"""

from authlib.common.urls import urlparse


def get_well_known_url(
    resource_identifier, external=False, suffix="oauth-protected-resource"
):
    """Build the well-known metadata URL from a resource identifier
    per :rfc:`9728#section-3.1`.

    By default returns a relative path (useful for registering the route in
    your application). Set ``external=True`` to get the full URL (useful for
    clients fetching the metadata)::

        from authlib.oauth2.rfc9728 import get_well_known_url

        get_well_known_url("https://api.example.com/")
     

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key