c# - ArcGIS portal - login in code without prompt -


i trying write program login user programatically arcgis portal.

here scenario:

user logs in application a, user clicks link arcgis portal - not want them have login portal when click link because have logged application a.

so

i like:

user logs in application a, user clicks button containing portal link argument , redirects application b. application b logs user portal , redirects them link application - user redirected without being prompted login.

the portal using portal tier authentication , using javascript use .net/c#

update:

my current solution looks this:

    var url = "https://portal_domain/portal/sharing/rest/generatetoken";     var redirect = "https://portal_domain/portal/home/webmap/place_i_want_to_redirect_to";      var params = {         'username': "username",         'password': "password",         'client': "referer",         'referer': redirect,         'expiration': 60,         'f': 'json'     };      $.post(url, params)         .done(function (data) {             var tokenholder = json.parse(data);             var token = tokenholder.token;             $('body').append(token);              document.cookie("esri_auth", token);             window.location = redirect;         }); 

this code gets me token rest service - try store has cookie doesn't persist.

i have tried using c# web request , credential cache generate credentials didn't save code using.

solved it:

okay, original post not far off needed. missing link cookie formatting , properties.

also important mention cannot run locally have has access portal server , works once published out.

in code below:

encoded cookie - url encoded json object. signed portal , copied cookie format (using chrome dev tools) , concatenated generated token cookie , redirected. had set domain,expire, , path properties of cookie.

    var url = "https://portal_domain/portal/sharing/rest/generatetoken";      var redirect = "https://portal_domain/portal/home/webmap/place_i_want_to_redirect_to";            var params = {               'username': "username",               'password': "password",               'client': "referer",               'referer': redirect,               'expiration': 60,               'f': 'json'           };            $.post(url, params)             .done(function (data) {                 var tokenholder = json.parse(data);                 var token = tokenholder.token;                 var domain = ".portal_domain";                  document.cookie = "esri_auth=encoded cookie;expires=session;domain=" +domain + ";path=/;secure";                  window.location = redirect;             }); 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -