Fixing some error handling
Added client_credentials and refresh_token grant type support