Write data via a secured GP service to the server - Token required error

1051
3
Jump to solution
02-16-2017 11:45 AM
Alexwang
Occasional Contributor II

Hello, my mapping application uses a GP service to save some info to a .txt located on the server. The GP service is secured through Portal. I was able to save data via the GP service rest endpoint without any issues. However, when I used JavaScript API to do that (codes are below) in WAB, the Modified Date of the file was updated but no data was saved.  "Error: token required..." was thrown in Concole. I guess this was related to the secured GP service. How to add a credential to the Geoprocessor? Thanks for your help!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

   When your register your app you get a appid and client secret:

https://developers.arcgis.com/applications/#/new/ 

http://doc.arcgis.com/en/arcgis-online/share-maps/add-items.htm#esri_section1_55703f1ee9c845c3b07bbd... 

You are probably better off using the username and password parameters in the ServerUrl instead, if you don't know about the clientSecret.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

   I would setup the proxy for that url in your proxy.config and set the proxy rule in your apps main config.

Use proxy—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers 

Setting up a proxy with Web AppBuilder Developer Edition | Support Services Blog 

0 Kudos
Alexwang
Occasional Contributor II

Thank you Robert always. I set it up like following, but threw "SyntaxError: Unexpected token <". I used Application ID for the clientId. Where to get the clientSecret?

config.json

proxy.config

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   When your register your app you get a appid and client secret:

https://developers.arcgis.com/applications/#/new/ 

http://doc.arcgis.com/en/arcgis-online/share-maps/add-items.htm#esri_section1_55703f1ee9c845c3b07bbd... 

You are probably better off using the username and password parameters in the ServerUrl instead, if you don't know about the clientSecret.

0 Kudos