Corrected service_provider_id returned in 401 responses

Corrects service_provider_id returned in 401 response from protected resources. This pull request also removes some unused code.