How to fix AADSTS50169 error when accessing ACS from SharePoint 2013

Irek Singer 0 Reputation points
2024-07-18T17:13:16.63+00:00

I followed these instructions:

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-an-office-365-sharepoint-site-to-authorize-provider-hosted-add-ins-on-an-on

but when I try to add a new Add-in app in SharePoint I get this error in ULS:

Application Authentication        aiv3i      High      An exception occurred during OAuth2 request to https://accounts.accesscontrol.windows.net/c0e654c4-1cf5-4bff-9b82-f6bfd63621ce/tokens/OAuth/2. Response: '{"error":"invalid_request","error_description":"AADSTS50169: The realm '7d681bd1-ba79-444c-8fc4-4311aeff36b4' is not a configured realm of the current service namespace. Trace ID: 3217f461-f197-4a81-a392-2c845e9f4600 Correlation ID: 8d893da1-e2cc-c0d3-5983-1f6a37b3911b Timestamp: 2024-07-18 15:18:10Z","error_codes":[50169],"timestamp":"2024-07-18 15:18:10Z","trace_id":"3217f461-f197-4a81-a392-2c845e9f4600","correlation_id":"8d893da1-e2cc-c0d3-5983-1f6a37b3911b"}'.  Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.     at System.Net.HttpWebRequest.GetResponse()     at Microsoft.SharePoint.I...   8d893da1-e2cc-c0d3-5983-1f6a37b3911b

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,817 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 26,761 Reputation points Microsoft Vendor
    2024-07-19T04:16:25.32+00:00

    Hi @Irek Singer ,

    Welcome to Q&A forum!

    The error message you are seeing indicates that the realm you are trying to use is not configured for the current service namespace. This can happen if the realm is not properly registered with ACS. To fix this issue, you can try the following steps:

    1. Make sure that the realm is properly registered with ACS. You can check this by going to the ACS management portal and verifying that the realm is listed under the "Relying party applications" section.
    2. Check that the client ID and client secret information in your SharePoint Add-in's web.config file are correct and match the information in the ACS management portal.
    3. Verify that the redirect URI specified in your SharePoint Add-in's registration matches the redirect URI specified in your web.config file.
    4. Check that the domain names in your configuration files and registration forms match exactly. This includes the Add-in Domain specified when the SharePoint Add-in is registered, the domain under which the remote web application's security certificate is registered, the domain part of the StartPage value in the AppManifest.xml file, and the domain part of the URLs of any event receivers specified in the AppManifest.xml.

    And please note that SharePoint Server 2013 has reached the end of its lifecycle, and Microsoft no longer provides any security updates or paid support. For the sake of your information security and better user experience, it is recommended that you upgrade to the latest version of SharePoint server or SharePoint Online.


    If the answer is helpful, please click "Accept as Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.