A rewrite to implement the XMLHttpRequest interface
Restored error handling
Refreshing tokens now works.