Select to view content in your preferred language

Using WMTS Service with API Key - not working

503
0
12-14-2022 05:42 AM
KobusPItzer
New Contributor

Hi 

I am currently using WMTS to display satellite data and we used bearer token previously. We are now moving to API Key usage with WMTS and setting the API key with custom params or 

 

ArcGISRuntimeEnvironment.setApiKey("MY_KEY")
wmtsService.customParameters["APIKEY"] = "MY_KEY"

 

 is not working. Keep getting authentication errors, such as ""No API key provided". 

 

What I currently have is 

private val wmtsService: WmtsService by lazy { WmtsService("https://api.airbus.geoint.africa/api/v1/map/imagery.wmts") 
ArcGISRuntimeEnvironment.setApiKey("MY_KEY")
wmtsService.customParameters["APIKEY"] = "MY_KEY"
// create a Map
val map = ArcGISMap()
// set the map to be displayed in this view
mapView.map = map

// display wmts data on the map
wmtsService.addDoneLoadingListener {
if (wmtsService.loadStatus == LoadStatus.LOADED) {
// get service info
val wmtsServiceInfo = wmtsService.serviceInfo
// get the first layers id
val layerInfos = wmtsServiceInfo.layerInfos
// create WMTS layer from layer info
val wmtsLayer = WmtsLayer(layerInfos[0])
// set the basemap of the map with WMTS layer
map.basemap = Basemap(wmtsLayer)
}
if (wmtsService.loadStatus == LoadStatus.FAILED_TO_LOAD){
Log.e("ARCGIS", "Load failed: ${wmtsService.loadError.cause}")
}
}
wmtsService.loadAsync()

It keeps failing and I get a grid of grey squares from the map view, any help would be appreciated.

 

Thanks

0 Kudos
0 Replies