I think this is a proxy issue. The proxy would need to be on the applications web server. The proxy url is set in index.html, look for the proxyurl option. The proxy isn't always used - but there are some situations when its needed. Another issue you might run into is that the identity manager expects the app to be running using https since you are working with secure items. If its not run over https then you might see the log-in dialog appear but it won't successfully log you in.
If you are working with only public web maps and services then the templates should work - its only going to be an issue when you are working with non-public maps.