add more logging and error handling to authorize
fix #1409?
Merge pull request #1426 from jlipps/master

add more logging and error handling to authorize