Select to view content in your preferred language

how to get authentication to persist between apps

3326
0
12-12-2014 03:30 PM
ClintKellar2
Deactivated User

I'm working on a gallery application that auto-populates content from a named user's organization content.

I started with the sample code here:

OAuth Popup | ArcGIS API for JavaScript

and modified it to only return web map applications.

I changed this original function:

function createGallery(items) {
       
var htmlFragment = "";
        arrayUtils
.forEach(items.results, function(item) {
          htmlFragment
+= (
           
"<div class=\"esri-item-container\">" +
             
(
                item
.thumbnailUrl ?
               
"<div class=\"esri-image\" style=\"background-image:url(" + item.thumbnailUrl + ");\"></div>" :
               
"<div class=\"esri-image esri-null-image\">Thumbnail not available</div>"
             
) +
             
(
                item
.title ?
               
"<div class=\"esri-title\">" + (item.title || "") + "</div>" :
               
"<div class=\"esri-title esri-null-title\">Title not available</div>"
             
) +
           
"</div>"
         
);

});

To this:

function createGallery(items) {

        var htmlFragment = "";

        arrayUtils.forEach(items.results, function(item) {

       if (item.type == "Web Mapping Application") {

              htmlFragment += (

                   "<a href='" + item.url + "' target='_blank'>" +

                    "<div class=\"esri-item-container\">" +

                   (

                   item.thumbnailUrl ?

                   "<div class=\"esri-image\" style=\"background-image:url(" + item.thumbnailUrl + ");\"></div>" :

                   "<div class=\"esri-image esri-null-image\">Thumbnail not available</div>"

               ) +

               (

                item.title ?

                "<div class=\"esri-title\">" + (item.title || "") + "</div>" :

                "<div class=\"esri-title esri-null-title\">Title not available</div>"

              ) +

            "</div></a>"

           );

            }

        });

The web map applications that are returned are either private to the named user logging in, or shared to the named user as a member of the organization.

The problem is, when I click on a hyperlinked app in the gallery, I am prompted again to login to the ArcGIS Online Organization. Anyone know of a way to get the authentication to carry over, when always hitting content in the same org?

Tags (2)
0 Replies