Select to view content in your preferred language

GeodatabaseSyncTask + token

5504
14
Jump to solution
08-25-2015 02:19 AM
ArneDahlman
Regular Contributor

Hi all!

Does any one know if it is possible to sync geodatabase using service that requires autentication (token)?

Generate geodatabase works fine with token, but when I try to sync my geodatabase back to server, it fails.

I am using a pregenerated long term token.

In fiddler I can se this response {"error":{"code":499,"message":"Token Required","details":[]}} after 401 challange,

I don't se any token in the post request, so I belive the problem is in my code or a bug in the .NET runtime.

My code:

var taskParameters = new SyncGeodatabaseParameters()

{

    RollbackOnFailure = false,

    SyncDirection = Esri.ArcGISRuntime.Tasks.Offline.SyncDirection.Upload

};

var gdbTask = new GeodatabaseSyncTask(uri);

gdbTask.Token = token; // pregenerated longterm token

GenerateGeodatabaseResult r = await gdbTask.SyncGeodatabaseAsync(taskParameters, gdb, syncCompleteCallback, null, new TimeSpan(0, 0, 3), progress, cancelToken);

I have tried this in both runtime 10.2.5 & 10.2.6.  (ArcGIS Server 10.22)

0 Kudos
14 Replies
ArneDahlman
Regular Contributor

Great!

The main reason is that we want to restrict the use of some map services to certain specific applications.

A user should be able to use a service in our .NET Runtime application, but not in a common map Viewer (without bussiness rules)

Also it helps monitoring/maintance of the services if you can see wich application causing load, etc in logs.

0 Kudos
AnttiKajanus1
Deactivated User

Is there any reason why you can't use IdentityManager to handle the token generation for you? You can also create a long term tokens using it and if needed, cache that to the client for reuse.

0 Kudos
ArneDahlman
Regular Contributor

Users should not need to input creedentials to use the application.

If it possible to use IdentityManager in the background then it should be ok.

0 Kudos
AnttiKajanus1
Deactivated User

Yes, that's possible. You have 2 ways to handle that. One is to include credentials to the application that are used in authentication or you can use a proxy. Read more from here​.

0 Kudos
ArneDahlman
Regular Contributor

Thank you!

0 Kudos