Portal login on redirect without prompt

04-11-2017 09:12 AM
New Contributor II

I am trying to write a program that will login a user programatically into a ArcGIS portal.

Here is my scenario:

User logs in to application A, user clicks a link to the ArcGIS portal - I do not want them to have to login to the portal when they click that link because that have already logged into application A.


I would like:

User logs in to application A, user clicks a button containing the portal link as an argument and redirects to application B. Application B logs the user into portal and redirects them with the link from application A - the user is redirected without being prompted to login.

The portal is using portal tier authentication and I am using javascript but I could also use .NET/C#


My current solution looks like 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 a token from the rest service - I try to store it has a cookie but it doesn't persist.

I have also tried using a C# web request and a credential cache to generate the credentials AND using the .NET proxy to try and pass through my portal URL and store the credentials server side but I didn't save the code I was using.

0 Kudos
0 Replies