Using ArcGIS SSO in Swift app to access organizations feature services.

420
4
Jump to solution
02-15-2024 05:23 PM
DuanePfeiffer
New Contributor III

I would like to present arcgis.com's Sign in screen to authenticate users.  So they can use SAML logins.  I'm using arcgis toolkit (swift) and Authenticator/AuthenticationManager but I always get the username and password dialog.  We were able to do this with UIKit but I'm not seeing how to do it using SwiftUI.  Help please....

0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor

Hi @DuanePfeiffer ,

Thank you for the code. Please, mask the license key you posted in the code. 

Sorry, I misunderstood your initial question. I thought you are getting prompted between application sessions even after providing credentials first time. However, look like you are prompted to enter the username/password instead of an OAuth login page. Is that correct?

 

If yes, is it because the  `OAuthUserConfiguration` expect a portal URL and you are passing the feature service URL?

portalURL: K.vegetationManagementFeatureServiceURL

 

Regards,

Nimesh

View solution in original post

0 Kudos
4 Replies
NimeshJarecha
Esri Regular Contributor

Hi @DuanePfeiffer ,

Are you setting up the persistent credential stores as shown in authentication example of the toolkit?

Regards,

Nimesh

0 Kudos
DuanePfeiffer
New Contributor III

Yes,  here is the code I'm using.

        let config = OAuthUserConfiguration(portalURL: K.vegetationManagementFeatureServiceURL,
                                           clientID: K.clientID,
                                           redirectURL: K.redirectURL)

        authenticator = Authenticator(oAuthUserConfigurations: [config])

        // Sets authenticator as ArcGIS and Network challenge handlers to handle authentication
        // challenges.
        ArcGISEnvironment.authenticationManager.handleChallenges(using: authenticator)
        Task {
            try? await ArcGISEnvironment.authenticationManager.setupPersistentCredentialStorage(
                access: .whenUnlockedThisDeviceOnly,
                synchronizesWithiCloud: false
            )
        }

 

 

0 Kudos
NimeshJarecha
Esri Regular Contributor

Hi @DuanePfeiffer ,

Thank you for the code. Please, mask the license key you posted in the code. 

Sorry, I misunderstood your initial question. I thought you are getting prompted between application sessions even after providing credentials first time. However, look like you are prompted to enter the username/password instead of an OAuth login page. Is that correct?

 

If yes, is it because the  `OAuthUserConfiguration` expect a portal URL and you are passing the feature service URL?

portalURL: K.vegetationManagementFeatureServiceURL

 

Regards,

Nimesh

0 Kudos
DuanePfeiffer
New Contributor III

You are correct.  I am now using "https://www.arcgis.com" and it is working.  Thanks!