Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using the ArcGIS Javascript API to connect to the arcgis.com portal. To do so I am calling portal.signIn(). The issue is that I don't want the user to be responsible for performing the login, bo I want to generate the REST API token on my server and then use that token from the Javascript API.

Mock code

portal = new esri.arcgis.Portal('http://www.arcgis.com');
dojo.connect(portal, 'onLoad', function() {
    portal.id.token="<server-side writes token here>";
    portal.signIn().then(function(loggedInUser){
        console.log(loggedInUser);
    });
});

EDIT:

From what I can tell in this sample http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/widget_identitymanager_client_side.html

I might be able to build my own credentials object to run esri.id.initialize() (which from what I understand is an implementation of esri.IdentityManager). I will try this and report back if it works.

share|improve this question
2  
You can hard code a 'Long-lived' Token into your script resources.arcgis.com/en/help/main/10.1/index.html#/… but must use the token service of arcgis server to generate it. –  Mapperz Jan 2 '13 at 22:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.