Improved error handling
I had to make a small change to get tests running on my environment. Then I added better checking on OAuth credentials, so the code doesn't fail out later with an obscure message. Finally, I brought the handling of error data in line with the handling of response data. This last does change behaviour, and if you don't want that, I can back out that change.