Select to view content in your preferred language

How Login with Gmail for the Arcgis Account used for ServiceGeodatabase.credentials?

1021
3
08-11-2021 02:37 AM
Latheesh
Emerging Contributor

I am working on creating versions of the maps while we require to create the service geodatabase 

ArcGISRuntimeEnvironment.setApiKey(BuildConfig.API_KEY)

// hardcode user credentials since this sample has been setup to work with this specific // service. Normally you'd handle authentication with the

AuthenticationChallengeHandler serviceGeodatabase.credential = UserCredential(getString(R.string.editor01_username), getString(R.string.editor01_password))

// load the service

geodatabase serviceGeodatabase.loadAsync()

I am confused about how to use the OAuth and provide user credentials as I logged in through Gmail 

 

0 Kudos
3 Replies
Latheesh
Emerging Contributor

I used authchallengehandler and provide the below code 

serviceGeodatabase=ServiceGeodatabase("https://services3.arcgis.com/df7XtT0Re4z8S561/arcgis/rest/services/Chimpanzee/FeatureServer","1")

        serviceGeodatabase.loadAsync()
serviceGeodatabase.addDoneLoadingListener {
if (serviceGeodatabase.loadStatus != LoadStatus.LOADED) {
serviceGeodatabase.loadError?.let {
Log.e("Tag", "Service Geodatabase failed to load: ${it.cause}")
}
return@addDoneLoadingListener
}
}
serviceFeatureTable=serviceGeodatabase.getTable(0)

Nothing works as feature table is always null

if i load the map with service url i am getting the map with no problem

 

0 Kudos
RamaChintapalli
Esri Contributor

Hi,

You can either work with API Keys or OAuth for authentication and you seem to have chosen OAuth.
https://developers.arcgis.com/android/security-and-authentication/

 

I looked at your FeatureService, you seem to have only one layer in it. If so, you might be better off just working with ServiceFeatureTable.
https://github.com/Esri/arcgis-runtime-samples-android/tree/main/java/feature-layer-feature-service

If you have multiple layers in your feature service, you can load them at once using ServiceGeodatabase.
An example,
https://github.com/Esri/arcgis-runtime-samples-android/tree/bd6ff32059f3956bed90c18b559c841b0cb683f1...

Also, you get the loadError and see the error message incase of a load failure.

 

Thanks

Rama

Latheesh
Emerging Contributor

I am doing the same creating the feature table and displaying. The main problem is when i  am trying to create different versions of map the sample code suggest to create servicegeodatabase where i am getting the error saying servicegeodatabase must be loaded.

0 Kudos