Select to view content in your preferred language

fetchLicenseInfo from Portal with username and password

580
5
01-05-2025 06:48 PM
SonMinh
Emerging Contributor

I have username and password from portal (ArcGIS Enterprise 11.2).  How can I get a LicenseInfo from that to set for ArcGISEnvironment in Kotlin Maps SDK? 

0 Kudos
5 Replies
RamaChintapalli
Esri Contributor

Hi,

You can load an enterprise portal with your credentials and fetchLicenseInfo from the portal.
Here is the documentation on how to set license info from user authentication.

Thanks
Rama

0 Kudos
SonMinh
Emerging Contributor

i've try with code below

 

val portal = Portal(url = "https://example.com/portal", connection = Portal.Connection.Authenticated)
portal.load().getOrElse { error ->
   Log.d("Err","Error loading portal: ${error.message}")
}
val licenseInfo = portal.fetchLicenseInfo().getOrElse { error ->
   Log.d("Err","Error fetching licenseInfo: ${error.message}")
   return
}
val licenseResult = ArcGISEnvironment.setLicense(licenseInfo)

 

And I see the log return 

 

A token or API key is required., additionalMessage=A token or API key was not provided to access 
https://example.com/portal/sharing/rest/portals/self., errorCode=18004

 

I think I missing set API key by

 

ArcGISEnvironment.apiKey = ApiKey.create("API key string")

 

And I check how to get API key string from portal (now my portal use ArcGIS Enterprise 11.2) and i see  API key credentials are not supported in ArcGIS Enterprise versions prior to 11.4.

 

SonMinh_0-1736234108674.png

So how can I get credentials to set for my portal in application?

0 Kudos
RamaChintapalli
Esri Contributor

For the enterprise portal, you can authenticate with OAuth. Here is a sample and a tutorial.

The tutorial and sample showcase it with ArcGIS Online portal, but you can reference it for enterprise login as well.

Rama

0 Kudos
SonMinh
Emerging Contributor

I see the sample and a tutorial but it's use Composable with com.arcgismaps.toolkit, now my project still use Android View with ArcGIS Kotlin SDK 200.6, not Composable, so how can i can authenticate?

0 Kudos
RamaChintapalli
Esri Contributor

We updated the authenticate with OAuth sample in 200.5.0 to use the toolkit Authenticator composable component which abstracts all the complexity. If you need to use it for view based sample, you can reference the 200.4.0 version of the same sample that is available here. More details on the custom authentication handlers is provided here

Rama

0 Kudos