Select to view content in your preferred language

how to authenticate with token only to get a route with routeTask.createFromToken("x")?

05-16-2023 06:01 AM
New Contributor

I'm trying to get a route with Arcgis routeTask adding the token obtained from the service but it doesn't work correctly, sometimes it succeeds in authenticating and other times it doesn't, could you please help me?

I am using the java sdk..

var credential: UserCredential = UserCredential.createFromToken(arcgisToken,"")
fun solveRoute(){
   val rouTask = RouteTask(appContext,"https://route-")
   rouTask.credential = credential          
   rouTask.addDoneLoadingListener {
override fun handleChallenge(p0: AuthenticationChallenge?): AuthenticationChallengeResponse {
        return AuthenticationChallengeResponse(


Tags (2)
0 Kudos
1 Reply
Esri Contributor


It looks like you are working with the ArcGIS Runtime API for Android or ArcGIS Maps SDK for Kotlin here. I'll move your post to that forum (this particular forum is for the Java Maps SDK to build apps for Windows, Linux and macOS platforms).

In the meanwhile, you might find it helpful to have a look at the Find Route sample on the Android-Java samples webpage, or the same sample on the Kotlin sample code page. The sample shows how to set up a route task. For authentication challenges, have a look at the Cloud and Portal section on the Sample Code homepage.

0 Kudos