mike4aday / SwiftlySalesforce

The Swift-est way to build native mobile apps that connect to Salesforce.
MIT License
136 stars 43 forks source link

Logout is failing #120

Closed camiloduqued closed 4 years ago

camiloduqued commented 4 years ago

I'm having issues with the logout since I updated Swiftly Salesforce to version 8.0.0, I added the package with the Swift Package Manager and updated the implementation to the Combine framework. Sometimes it fails and sometimes it's successful.

When it fails the request made at the OAuthManager revoke function responds with a status 404 and the body (data) is "Bad_Id".

It's weird because that error is not supposed to be sent at the revoke endpoint, so the code maps it to an OAuthManagerError.endpointFailure with code "Unknown".

image

The request URL and the body are fine, I even tried to make the same request separately (but using query parameters instead of body) with the same token and it was successful. I think this was a coincidence because I edited the code to use query parameters and it's still failing.

mike4aday commented 4 years ago

Thanks @camiloduqued - I've not seen this before and will try to figure out what's going on. Were you able to see if the token was revoked on the Salesforce side?

camiloduqued commented 4 years ago

No @mike4aday, the token was not revoked, even as it fails the user is not removed from the User Defaults, so when I try to login again, it skips the Salesforce Login and all the subsequent requests are successful.

mike4aday commented 4 years ago

Thanks @camiloduqued - I'll look into this.

mike4aday commented 4 years ago

Hi @camiloduqued - which OAuth scopes did you select in your Connected App definition?

camiloduqued commented 4 years ago

Hi @mike4aday, I selected these scopes: image

mike4aday commented 4 years ago

Hi @camiloduqued - I'm still checking into this. As you noted, 404 and "Bad_Id" is not documented as a possible result of a call to the OAuth 'revoke' endpoint. Back to you soon.

mike4aday commented 4 years ago

@camiloduqued - I asked experts at Salesforce and so far the only possible explanation is that the request to the 'revoke' endpoint is coming from an 'invalid domain.' Are you able to provide a trace route of the path from the caller to the 'revoke' endpoint? Approximately how often do you see the failure (as % of all calls to revoke)? I've not been able to replicate the issue.

mike4aday commented 4 years ago

@camiloduqued I'll close this for now; re-open if needed.