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

Implementation in ipad Swift Playground. AuthenticationError #149

Closed
unoctanium opened this issue Apr 2, 2023 · 3 comments
Closed

Implementation in ipad Swift Playground. AuthenticationError #149

unoctanium opened this issue Apr 2, 2023 · 3 comments
Assignees
Labels

Comments

@unoctanium
Copy link

unoctanium commented Apr 2, 2023

Hi,

I tried to implement a test app in Swift Playgrounds, following your example code.
Problem: if Salesforce.connect is run, a new popup opens in the app:

MyApp wants to use "salesforce.com" to sign in
This allows the app and website to share information about you.
Cancel , Continue

Pressing continue opens new window:
Title: login.salesforce.com
Window content: a document icon with a question mark, the thext „authorize“, the text „data - 71 bytes“, a buttom „open in“ (which would let me open the document in a lot of useless apps) and a cancel button.

Pressing cancel reslts in an error message:
The operation couldn‘t be completed. (com.apple.AuthenticationServices.WebAuthenticationSession error 1.)

Btw: the contents of the 71 byte answer is:
error=invalid_client_id&error_description=client%20identifier%20invalid

and Salesforce.json is in place and correctly configured.
I copied the consumer key and the callbackURL from my salesforce connected app

and in salesforce the settings for the connected app are:

Selected OAuth Scopes:
Full access (full)
Perform requests at any time (refresh_token, offline_access)

callbackURL:
connapp://callback

Seems like I have a problem with OAuth?
Do you have any idea how to fix that?

@mike4aday mike4aday self-assigned this Apr 2, 2023
@mike4aday
Copy link
Owner

Hi @unoctanium I have never tried Swiftly Salesforce in the iPad Playgrounds app. Swiftly Salesforce uses ASWebAuthenticationSession with OAuth, which launches Safari to display Salesforce's login page. Can you "open in..." Safari? I don't know if that would even work since Swiftly Salesforce has to parse the callback URL from Salesforce.

@unoctanium
Copy link
Author

unoctanium commented Apr 3, 2023

Hi @mike4aday
Thank you for the hint.
This issue can be marked as completed.
Here is how I resolved:

In the Salesforce.json, I added a line:

"authorizingHost": "<mySite>.my.salesforce.com"

Where <mySite> is the beginning of the URL of my dev-environment.

It seems like we have to use different authorizing hosts, depending on how we want to connect:

  • Production: login.salesforece.com
  • Sandbox: test.salesforce.com
  • DevAccount: <mySite>.my.salesforce.com

At least in my case that solved the issue.

@mike4aday
Copy link
Owner

mike4aday commented Apr 6, 2023

@unoctanium FYI even if you use the default authorizing host, login.salesforce.com: when the Salesforce-hosted login form is displayed, you can click "Forgot Your Password" and then "Sandbox Login" -- or "Use Custom Domain" and then enter a 'My Domain' name -- to use non-default authorizing hosts.

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

2 participants