Using FeatureServiceManager

768
2
Jump to solution
03-30-2017 11:42 AM
KE
by
Occasional Contributor

I have a question about working with secured feature services in the Quick Report App. I thought adding the username and password into the appinfo.json file under properties would work,

    "properties": {
        "password": "password",
         "username": "username",

but I get this error:

 

I can get the app to work by plugging the username and password into this line in FeatureServiceManage.qml under the generateToken function:

var obj = {"username":"username", "password":"password", "f":"json", referer: "http://www.arcgis.com"/*, expiration:"1"*/};

But my guess is that’s not how it is supposed to work. Am I missing something?

I am using AppStudio for ArcGIS (Desktop Edition) 1.4.18 and the Quick Report template.

My app is for the public to submit sensitive information to a public safety customer. So I need for the public to be able to edit the feature service, but I do not want the public to be able to access the rest endpoint of my feature service.

0 Kudos
1 Solution

Accepted Solutions
LiweiGao
New Contributor II

Hi Kristen,

Glad to help you about this issue.

If you simply set username and password in the appinfo.json without any code change, it would not help you to generate token automatically. This is because the app always tries to read username and password from app's settings file (which is different from appinfo.json). The appinfo.json, on the other hand, is used to configure the app when you initialize it.

In details, the appinfo.json is used to initialize the app (you cannot change in the app). The settings file is the file which saved all information you want to change and keep when you open the app next time.

In your case, you want to use a secured service without asking users to input the username and password. This is easy to do by using the template. Just do the following things:

- set username and password in the appinfo.json (which you have already done)

- Inside the function generateToken(), using

var user = app.info.propertyValue("username","");
var pwd = app.info.propertyValue("password","");
var obj = {"username":user, "password":pwd, "f":"json", referer: "http://www.arcgis.com"/*, expiration:"1"*/};

This will read the username and password from the appinfo.json and try to use them to generate token.

Hope this will help!

Best,

LG

View solution in original post

2 Replies
LiweiGao
New Contributor II

Hi Kristen,

Glad to help you about this issue.

If you simply set username and password in the appinfo.json without any code change, it would not help you to generate token automatically. This is because the app always tries to read username and password from app's settings file (which is different from appinfo.json). The appinfo.json, on the other hand, is used to configure the app when you initialize it.

In details, the appinfo.json is used to initialize the app (you cannot change in the app). The settings file is the file which saved all information you want to change and keep when you open the app next time.

In your case, you want to use a secured service without asking users to input the username and password. This is easy to do by using the template. Just do the following things:

- set username and password in the appinfo.json (which you have already done)

- Inside the function generateToken(), using

var user = app.info.propertyValue("username","");
var pwd = app.info.propertyValue("password","");
var obj = {"username":user, "password":pwd, "f":"json", referer: "http://www.arcgis.com"/*, expiration:"1"*/};

This will read the username and password from the appinfo.json and try to use them to generate token.

Hope this will help!

Best,

LG

View solution in original post

KE
by
Occasional Contributor

Thank you!

0 Kudos