AnsweredAssumed Answered

pulldata @json to query Feature Service; Need help with security token

Question asked by wws_ahargreaves on Jan 7, 2019
Latest reply on Jan 11, 2019 by wws_ahargreaves

Hello Survey123 for ArcGIS Team

 

I'm attempting to use the example given in the Custom pulldata() JavaScript Functions

here. However, I'm struggling with how to request a security token. Here's my setup:

  1. I query a Feature Service for a particular feature ID using the below:

    var url = "https://services1.arcgis.com/xxxxxxx/arcgis/rest/services/xxxxxx/FeatureServer/0/query?where="

    +"FACILITYID+%3D+%27" + ID +"%27"
    +"&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=*&returnHiddenFields=false&returnGeometry=true&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=BIG OLD SECURITY TOKEN"
  2. The above URL works great, and returns a JSON object for the desired feature that I can parse out and populate various fields within my Survey. However, I got that URL from experimenting with the Service URL query function. Because I was logged into to AGO when doing that I got a security token as part of the URL.

 

However, now I'm struggling with how to go about adding in a token request to my JS script. So:

  1. Is there a way to register this app in order to follow these steps?
  2. Or, is there a method to pull a users password (I know there's one for username)? 
  3. Or, the example given in the Custom pulldata() JavaScript Functions here includes the below. However, there's no further documentation on how I use the 'token' property to pull a token:

"Sometimes, particularly when using JS to access web services and secure ArcGIS services, you may need some properties that are not available through standard XLSForms. For this reason, we have also extended the collection of properties you can obtain through property() function as follows:

property('propertyname')

  • portalurl
  • token

..."

Any help would be greatly appreciated.

 

 

 

 

Jake Skinner

Outcomes