arcgis-maps-sdk-swift-toolkit icon indicating copy to clipboard operation
arcgis-maps-sdk-swift-toolkit copied to clipboard

Authenticator: Can the OAuth configs be a read/write property?

Open rolson opened this issue 10 months ago • 1 comments
trafficstars

It would be great if the oauth configs could be a readwrite property. As it is now, I have to assign a brand new Authenticator if the oauth settings change:

...
            .onChange(of: oAuthSettings.userConfiguration) { oldValue, newValue in
                // When the oAuth settings change, must create new authenticator.
                Logger.authentication.info("OAuthUserConfiguration has changed.")
                setupAuthenticator()
            }
            .onChange(of: oAuthSettings.useOAuth) {
                Logger.authentication.info("OAuthSettings `useOAuth` has changed.")
                setupAuthenticator()
            }
        }
    }
    
    func setupAuthenticator() {
        var configs = [OAuthUserConfiguration]()
        if oAuthSettings.useOAuth, let config = oAuthSettings.userConfiguration {
            configs.append(config)
        }
        authenticator = Authenticator(promptForUntrustedHosts: true, oAuthUserConfigurations: configs)
        ArcGISEnvironment.authenticationManager.handleChallenges(using: authenticator)
    }

cc @njarecha

rolson avatar Dec 23 '24 23:12 rolson

Yes, making this a readwrite property will be helpful for our users.

njarecha avatar Jan 08 '25 00:01 njarecha