Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth error message confusing to user. #27

Closed
ghost opened this issue Mar 12, 2017 · 2 comments
Closed

OAuth error message confusing to user. #27

ghost opened this issue Mar 12, 2017 · 2 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Mar 12, 2017

Recently, my testing indicate that the OAuth server (mostly on US weekends) fails with "User authentication required". Attempts to re-authenticate fail as well. From the code below, looks like 401,403 is the reason. Could you please elaborate on the root cause, and if it is (as we believe) a server issue, sharpen the error message to the user?

fileprivate func send<T,U>(urlRequest: URLRequest, jsonDeserializer: @escaping (U) throws -> T) -> Promise {
return Promise {
fulfill, reject in
Alamofire.request(urlRequest)
.validate {
(request, response, data) -> Request.ValidationResult in
switch response.statusCode {
case 401, 403:
return .failure(SalesforceError.userAuthenticationRequired)

@mike4aday
Copy link
Owner

Hi @pbrondum SalesforceError.userAuthenticationRequired is not intended to be exposed to the end user; it is a signal to Swiftly Salesforce that user authentication is required, and Swiftly Salesforce will then display the Salesforce-hosted OAuth authentication and authorization forms.

Salesforce.userAuthenticationRequired is thrown whenever Salesforce rejects a request and returns an HTTP status code of 401 or 403. Those status codes are explained here: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm and here: https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/oauth_using_identity_urls.htm

A status code of 401 is the more common error - it can occur when the session ID has expired, or if the refresh token has been revoked.

A status code of 403 could indicate that the org doesn't have API enabled (e.g. Professional Edition without optional API add-on), or that the username is associated with a different org, for example.

What did you mean by "re-authentication fails as well"? That the Salesforce-hosted login or authorization form displays an error? Or that the refresh token cannot be used to get a new access token?

Given the above, it would be helpful if Swiftly Salesforce acted differently in the case of a 403 error caused by lack of API support. There's no point having a user of Professional Edition without API log in again since authentication will not solve the problem. I'll add that enhancement in an upcoming version.

@mike4aday
Copy link
Owner

See issue #29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant