0

This problem has occurred in a few of our applications that use the same forms of salesforce oauth authentication.

When you first navigate to mywebsite.com, it sends you to salesforce to login, once you login, you get redirected in a loop like this:

mywebsite.com

https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=....

https://mycompany.my.salesforce.com/setup/secur/RemoteAccessAuthorizationPage.apexp?....

https://mywebsite.com/authentication/callback?display=page...

mywebsite.com ...LOOP CONTINUES FOREVER

There are dozens of details I could include, but I'm not sure which ones are relevant. To start: this is a .NET Framework application, using the Owin.Security.Providers.Salesforce nuget package, running on IIS on a windows AWS server.

This code works fine in dev (localhost) on my machine, it works on multiple production boxes, and only fails on a new server with a new test environment. The salesforce app settings are the same between all three environments except for the URLs, which work, plus the client ID and Secret, which are properly pasted into my test web config.

Is there any way to debug this? What other details would help here?

  • Are you storing the response in a cookie or any other means (i.e. browser cache) once they complete the sign in and checking this on the load of your home page to determine if the user's have already authenticated? It sounds like this is not happening, or is not being retained – Ronnie Jan 25 at 17:22
  • @Ronnie the response token is stored in a cookie. I think the library code is not liking the token for some reason but after putting throw statements in the controllers, they don’t actually throw, so I think the failure is happening in the Salesforce library code where I can’t debug it. – JacobIRR Jan 25 at 20:29
  • you can debug it if you start debugging once you enter your code and step through it in console. I would start there first this way you can walk your way through and take a look at what you're seeing when you come back to your check. obviously there is some issue after it comes back to your page. would be interesting to check the cookie contents on the return. – Ronnie Jan 26 at 1:51
1

The problem was related to IIS not allowing cookies for my test domain. I had to change the node in the web.test.config to use the new domain. Hopefully this helps someone in the future.

| improve this answer | |
  • 1
    We had a similar issue recently that only affected chrome. It was tied to the site settings for cookies, wasn't widespread, only based per user. Also caused lightning to load super slow. – Ronnie Jan 28 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.