AnsweredAssumed Answered

Android Offline Tiles, User Credentials and Tokens

Question asked by billmyers1 on Nov 5, 2015
Latest reply on Jan 4, 2017 by ANohe-esristaff

I'm developing an app using the ArcGIS Runtime SDK for Android.  I'm accessing tiled basemaps from arcgis.com using the following code which works fine.

 

UserCredentials creds = new UserCredentials();

creds.setUserToken("token", "referer");

String mapUrlUsaTopo = "https://services.arcgisonline.com/arcgis/rest/services/USA_Topo_Maps/MapServer";

mBasemapLayer = new ArcGISTiledMapServiceLayer(mapUrlUsaTopo, creds);

 

But... when I attempt to download the map tiles for offline use I get the following error: com.esri.core.io.EsriSecurityException: Message: Unable to generate token. Details: 'username' must be specified., 'password' must be specified.

 

Here's the download code:

String tileUrlUsaTopo = "https://tiledbasemaps.arcgis.com/arcgis/rest/services/USA_Topo_Maps/MapServer";

final ExportTileCacheTask exportTileCacheTask = new ExportTileCacheTask(tileUrlUsaTopo, creds);

 

Is the only option hard coding the username and password?

Outcomes