Detect and wrap api errors (oauth)