So, I am doing some digging into an older app using the runtime sdk, and was trying to reproduce some functionality using the Maps SDK.
In the old app, they are creating a service feature table, authenticating and then performing a query, something like this:
someService = AGSServiceFeatureTable(<with an url>)
// then setting credentials (to be used only with the service)
someService?.credential = AGSCredential(
user: environment.portal.username,
password: environment.portal.password
)
// some more code, setting featureRequestMode, etc
// then perform a queryFeatures on the service
However, in the new SDK, I think the equivalent service is the ServiceFeatureTable? But, I cannot set the credentials the same way. I am of course getting an error message indicating missing credentials.
My question is, is it possible, and if, how would I do this?
The problem is that I am to actually authenticate to a different service for other functionality, and this is a secondary "helper" service, and not really connectable with the other one, so it would be great to be able to fire up a authenticated connection on-the-fly.
Solved! Go to Solution.
Hi Frank,
Like 100.x SDK, the credential property is not available in 200.x SDK. Please refer the Migrate authentication from 100.x to 200.x doc for all the differences.
You can create the credential and add it to the store before creating and loading the service feature table.
let tokenCredential = try await TokenCredential.credential(
for: URL(string: "<service feature table url>")!,
username: "username",
password: "password"
)
ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(tokenCredential)
let table = ServiceFeatureTable(url: URL(string: "<service feature table url>")!)
try await table.load()
Hope this helps!
Regards,
Nimesh
Hi Frank,
Like 100.x SDK, the credential property is not available in 200.x SDK. Please refer the Migrate authentication from 100.x to 200.x doc for all the differences.
You can create the credential and add it to the store before creating and loading the service feature table.
let tokenCredential = try await TokenCredential.credential(
for: URL(string: "<service feature table url>")!,
username: "username",
password: "password"
)
ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(tokenCredential)
let table = ServiceFeatureTable(url: URL(string: "<service feature table url>")!)
try await table.load()
Hope this helps!
Regards,
Nimesh
Perfect, this was just what I needed! Absolutely brilliant 🙂