502 Bad Gateway Error for OAuth2 Callback on AWS Deployment

Harsh 5 Reputation points
2025-02-04T12:51:04.76+00:00

Experiencing a 502 Bad Gateway error when implementing the Microsoft Authentication flow. The entire flow works on the local machine, but an error occurs after deployment on AWS.

Redirect URL has HTTPS and it is correct.

{"message":"Service request error: Expecting value: line 1 column 1 (char 0)","status":"Bad Gateway","status_code":502,"timestamp":"2025-02-04T11:37:29.385445+00:00"}
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
3,021 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. BANDELA Siri Chandana 1,485 Reputation points Microsoft Vendor
    2025-02-05T06:15:40.7466667+00:00

    Hi @Harsh
    Thank you for posting your issue on Microsoft Q&A.

    I understand that you are encountering 502 Bad Gateway Error for OAuth2 Callback on AWS Deployment.

    The error 502 Bad gateway which comes from the server. Based on your trials I found this is working in your local machine perfectly fine but when it is deployed in AWS you have started facing the issue. This might be because the local machine does work with internal connectivity as there is no external connectivity required. Whereas to reach AWS it may need to connect over a public internet which may need to be checked your connectivity configuration. This may result in connectivity breakdown and resulted in no response situation from server. 

    For troubleshooting follow the document: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-troubleshooting-502?source=recommendations#request-time-out Hope this helps. Do let us know if you have any further queries.

    If this answers your query, do click `Accept Answer` and `Yes`.

    Thanks,

    B. Siri Chandana.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.