Login ArcGIS online in background using Identity Manager

767
1
04-24-2013 11:11 AM
tonylife
New Contributor III
I am not able to do background login and get item from ArcGIS online somehow.

What I am doing is, I manually generateToken using IdentityManagerBase and then manipulate cookie information with tokeninfo.

Then I use esri.id.initialize with cookie to re-hydrate the state of identity manager. But login window would still pop up to ask for credential.

However If I simply use popup window to login first time and let IdentityManager to handle cookie, it does work. I don't get pop up anymore.

Here is the IdentityManager generated cookie
{"serverInfos":[{"server":"http://www.arcgis.com","tokenServiceUrl":"https://www.arcgis.com/sharing/generateToken"}],"credentials":[{"userId":"MYUSERID","server":"http://www.arcgis.com","token":"1Ukoeka9lU2yjIYVlZls1ryjziqwr9VXr8du1WL6UQUfZHiIZ3JxhSZIaVx4-p3Ce4dZh_mnwMUKTerzgtvohC6TfAZr-F7kmAp6Gc6T8I5GrFIQVmIFF-B9NGDbSHv3zYkFB1IZ7H-Ffw3fZlRQaQ..","expires":1366830106409,"ssl":false,"creationTime":1366826506409,"resources":["MYRESOURCE"]}]}

Here is the cookie I manipulated
{"serverInfos":[{"server":"http://www.arcgis.com","tokenServiceUrl":"https://www.arcgis.com/sharing/generateToken"}],"credentials":[{"userId":"MYUSERID","server":"http://www.arcgis.com","token":"VE0L7bzjaGGWij17aa15Gwqnv7NFfoHOHYeSL97gfqeoK1NI7hK4DTW7KE4V1Ec3Cyq2tOjnKfCHwAAdQKCA3dnmshqS0mOeQHocH0zdcAzZQSVb3BUeWuFbyYGN4awrVQ8U1bk52KrkYcNngo-36Q..","expires":1366830235531,"ssl":false,"creationTime":1366826635531,"resources":["MYRESOURCE"]}]}

I compared both cookies, and it seems that only difference is token.

Here is the code for generateToken. Am I missing something?

var idBase = new esri.IdentityManagerBase();
    var serverInfo = {
        "server": "http://www.arcgis.com",
        "tokenServiceUrl": "https://www.arcgis.com/sharing/generateToken"
    };
    var def = idBase.generateToken(serverInfo, { "username": "MYUSERNAME*", "password": "MYPASSWORD", "client": "referer", "referer": "http://MYIP:MYPORT/index.html" });


BTW, I am running app in localhost right now.
Any thought would be appreciated!

Tony
0 Kudos
1 Reply
SamLarsen
New Contributor III
Tony,
I am attempting to do the same thing and running into the same problems.
Did you get this to work?

Sam
0 Kudos