OAuth autorization error in web application

We are trying to develop Web service, which uses Smart Things and we cannot resolve problem with authorization process. We still get the same error:

Error 500: Internal Server Error
URI /oauth/authorize
Reference Id 1aef0883-f3aa-49f9-86e2-7108da7699d4
Date Tue Sep 27 15:00:41 UTC 2016

We have created SmartThings application, enabled OAuth from the App Settings and published it to ourselves. Now, from the sevice we are trying to call:

https://graph.api.smartthings.com/oauth/confirm_access?response_type=code&client_id=<OUR_CLIENT_ID>&scope=app&redirect_uri=http://localhost

but with no success. When we try to authorize one of our locations, we always get the same error (500: Internal Server Error).
If we have understood right, after authorizing the location, we should be redirected to the page, which we set in ‘redirect_url’ param and we should get the token. But in our case, we get only error and the redirection never happens.
Could someone help us to resolve this problem?

A couple of things to check

Have you used an external app like postman?

Take a look at the docs here

http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/authorization.html

Hope that helps, I would be glad to help troubleshoot with more info.