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