[Python] Authlib Oauth2 Azure ssl error "The request body must contain the following...

Discussão em 'Python' iniciado por Stack, Março 13, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use Authlib 1.5.1 to authenticate against backend, using Azure as an authentication provider. My configuration is simple, I'm trying to follow docs:

    oauth.register(
    'azure',
    server_metadata_url=app.config['AZURE_METADATA_URL'],
    client_id=app.config['AZURE_CLIENT_ID'],
    client_secret=app.config['AZURE_CLIENT_SECRET'],
    client_kwargs={
    'scope': 'api://XXXXX0-YYYYY-ZZZZZZZZZZZZZ/api.access',
    }
    )


    Flask app config file is simple as well:

    import os
    from config_reader import config

    TENANT_ID = 'XXXXX0-YYYYY-ZZZZZZZZZZZZZ'
    AZURE_CLIENT_ID = os.getenv("AZ_CLIENT_ID")
    AZURE_CLIENT_SECRET = os.getenv("AZ_CLIENT_SECRET")
    AZURE_AUTHORITY = f'https://login.microsoftonline.com/{TENANT_ID}'
    AZURE_REDIRECT_URI = config['callback_url']
    AZURE_ACCESS_TOKEN_URL = f'https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token'
    AZURE_AUTHORIZE_URL = f'https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/authorize'
    AZURE_API_BASE_URL = config['api']['url']
    AZURE_METADATA_URL = f'https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration'


    Variables seems to be propagated properly, but on oauth.azure.authorize_access_token() I am getting error

    authlib.integrations.base_client.errors.OAuthError: invalid_request: AADSTS900144: The request body must contain the following parameter: 'client_id'.


    What am I missing?

    Continue reading...

Compartilhe esta Página