This might be related to your problem. See more information at this linklink. Basically Salesforce has a bug in terms of pulling down the connected app from live when you do a refresh. It might explain the second problem you have experienced and it might solve the first problem with the failure to log in. Maybe creating a different connected app with a different name in the sandbox and then change the login details and the name of the connected app in your third party app. See if it logs in every time, hope it helps