Skip to content

oauth2 code flow: Azure returns error AADSTS500112 #828

@pedrobtz

Description

@pedrobtz

redirect_uri = redirect_uri,

When performing an "oauth2 code flow" to Azure, and not setting the argument redirect_uri (using the default "http://localhost"), Azure returns error AADSTS500112.

Error in outh_flow_auth_codeO):
! OAth failure [invalid_client]
AADSTS500112: The reply address "http://localhost' does not match the reply address
'http://localhost:18894/° provided when requesting Authorization code. 

When oauth_flow_auth_code uses the default redirect URI from oauth_redirect_uri() (and it returns "http://localhost/"), the subsequent call to normalize_redirect_uri() adds a random port, creating a mismatch between the authorization and token requests.

This causes OAuth providers (e.g., Azure AD) to reject the token exchange with "reply address does not match" errors, as the redirect$uri in the first request differs from the second redirects_url.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions