Add better detection of oauth errors returned from resource owners

Fix for #325