question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] AADSTS50196: The server terminated an operation because it encountered a loop while processing a request

See original GitHub issue

Which Version of MSAL are you using ? MSAL 4.12.0

Platform net462

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Auth
    • Username Password
    • Device code flow (browserless)
  • Web App
    • Authorization code
    • OBO
  • Web API
    • OBO

Other? - please describe;

Is this a new or existing app? c. This is a new app or experiment

Repro Each requests from the desktop application to the backend a token is requested. This is happening from multiple threads.

        public IPublicClientApplication App {get;set;}
        ...
        public async Task<AuthenticationResult> AcquireTokenAsync(IAccount account) 
        {
                return await App.AcquireTokenSilent(Scopes, account)
                    .WithAuthority(AadAuthorityAudience.AzureAdAndPersonalMicrosoftAccount)
                    .ExecuteAsync();
        }

Expected behavior I thought that App would cache the tokens and only acquire a new token when it is (nearly) expired?

Actual behavior Exception is thrown. AADSTS50196: The server terminated an operation because it encountered a loop while processing a request

Possible Solution Should I cache the token myself or lock the App instance for single use only?

Additional context/ Logs / Screenshots Seems the Javascript MSAL library had the same issue https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/547

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
bgavrilMScommented, Apr 28, 2020

@rfcdejong - the error you are getting seems to indicate that the server is throttling you. This can occur if a variety of situations:

  • you call AAD too often with same request
  • AAD is having problems and is asking you to back off (but more likely is the 1st issue)

It may be that your app is retrying the same request too often, maybe there is a bug in your async handling or in some retry policy?

Some thoughts on high availability that might help: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/High-availability

@jmprieur - client side throttling was not released in 4.12, it will be available in 4.13. The server behavior when it detects a loop is to break the loop by sending an “invalid_grant” suberror, which MSALs interpret as “UI Required Exception”. I am not sure if a retry-after header is sent, probably not. At some point, we want the server to send HTTP 429 / Retry-After X messages instead, but discussions are still ongoing. Without this signal, client side throttling will not work. Oh, and for now, client-side throttling will not be enabled on confidential client flows. So probably 4.14 if we decide it’s a good idea?

1reaction
bgavrilMScommented, Aug 19, 2021

@ashinzekene - please open a new issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

edgeAADSTS50196: The server terminated an operation ...
Message: AADSTS50196: The server terminated an operation because it encountered a client request loop. Please contact your app vendor.
Read more >
AADSTS50196: The server terminated an operation ...
Correct, if you get this error, it is because your requests are being throttled, which is due to making too many request in...
Read more >
How to fix an AADSTS50196 error on Microsoft web properties?
The actual error message seems to usually be “AADSTS50196: The server terminated an operation because it encountered a client request loop.
Read more >
Azure AAD MSAL calls resulting in AADSTS50196 ...
Azure AAD MSAL calls resulting in AADSTS50196 exception The server terminated an operation because it encountered a client request loop.
Read more >
How to Fix AADSTS50196 Authentication Error on ...
Solution 1: Clear Default Web Browser Cache & Cookies​​ As discussed in the causes, a corrupted browser cache may block Microsoft's implicit ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found