How do I get a handle on the ArcGIS user token?
I've searched the forum and there were a few threads with suggestions, e.g. using the GetLayer and ParseUrl activities. Unfortunately this doesn't seem to work for me, as soon as I use the ParseUrl activity in a workflow I get errors (even with a hard-coded URL) - what am I doing wrong, and what is the best way to get a handle on the user token?
-
I found a solution that works for me. Using the Geocortex Workflow 5 SDK I created a simple custom activity that runs a single line of code and outputs the result so I can use it in downstream activities:
var t = eval("esri.id.credentials[0].token");
I'm not much of a front end developer which is why it took me a while to remember that within a JavaScript app I have global scope. This means I can execute code that references the identity manager singleton (esri.id) which is guaranteed to be available in a WAB app at runtime. No imports/requires needed in my activity, yay. Hopefully this is useful to others with a similar problem.
0 -
Hi Jan! How could I go about implementing your suggested solution?
0 -
Hi Laura,
A great place to start is Latitude's blog post at http://www.geocortex.com/about/blog/archive/workflow-sdk which talks about the SDK and has links to relevant resources.
In a nutshell you'll need to download the SDK and set up a dev environment on your computer, this includes installing npm and Visual Studio Code. I'm also using the Web AppBuilder Developer Edition for testing my custom activities and am finding the workflow really easy. You'll also need a web server to host your activity pack once you're done developing.
For full instructions of how to set everything up, refer to the README.md in the root of the SDK. I got stuck a few times but found everything I needed to carry on in this file every time.
Once you're up and running with your dev environment and you have created an activity pack, all you need to do is define inputs and outputs for your activity as required, and then implement your business logic in the execute method. In my case this was the one-liner I posted (no inputs and just the default string output), but please be aware that my code is a quick fix for a fairly specific problem, so may not work in all cases. If you had more than one credential per session (not sure how likely this is nowadays with collaboration and cross-organisation sharing available in Portal/Agol), you'd need to work out which credential's token to retrieve, and this may be a bit harder than just calling 'eval'.
I hope this helps get you started, I'd be interested to hear how you go.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
3 kommentarer