Automated named user login for agol hosted feature layer

849
7
11-30-2017 09:01 AM
LeoEger1
New Contributor II

Hi,

i got some questions regarding automated user login for non publicly shared content in agol. To be more precise the users should be able to load and edit a feature layer (portable item) hosted on arc gis online without having to fill in their username and password for the account. 

After reading many guides and threads in this forum it seems to me as if its not possible to do this with app login. 

Limitations of App Login

App login comes with several built-in limitations:

  • Tokens obtained by applications can only read public content and services. Although you cannot use an App login with private content, if your goal is to distribute or sell an app to organizations without ArcGIS Online (no named users), you may control access to your content by using your own login mechanism (I.e. Identity) to the app.
  • Tokens obtained by applications may read premium content and services hosted by Esri and consume credits on behalf of the application organization.
  • Applications cannot create, update, share, modify, or delete items (layers, files, services, maps) in ArcGIS Online or Portal for ArcGIS.
  • Applications built using app login cannot be listed in the ArcGIS Marketplace.

So what is the best approach to do this? Is there for example a way to do the named user login but without the individual user having to fill out the form every time he uses the app?

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
MichaelLodes2
Occasional Contributor

Thank you Robert for your answer.

We don't have acces to a dedicated/virtual server. We just have a ftp and a mysql database hosted on strato.de. Can we use the so called CORS on PHP (by adding "

<?php  header("Access-Control-Allow-Origin: *");"

to the php script)?

Or do we have to get a server for that?

Best Regards,

Leo

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Leo,

  Yes you would need to host the app and proxy on your own server in order to get what you are after.

0 Kudos
MichaelLodes2
Occasional Contributor

OK, that means

- we need a virtual/dedicated server to configure there PHP Apache/Java ApacheTomcat/DotNet IIS

- app (javascript application files) has to be executed on the same server

Kind Regards,

Michael

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Michael,

   Yes your own server setup as a web server (i.e. IIS enabled). You then need to download and configure GitHub - Esri/resource-proxy: Proxy files for DotNet, Java and PHP. 

This is the portion that will auto login to secured resources.  The you will configure your app with the proxy url.

LeoEger1
New Contributor II

Thank you for the response. After some downtime i'm back to figuring out this task. To better understand the process of setting up the proxy i'm now trying to follow the routing and directions example. (Directions widget | ArcGIS API for JavaScript 4.6 )

If set up an file on an IIS server. Now im not sure which app id and secret i have to use. Building an application in arc gis for developers returns me a clientId and a clientSecret. Adding a service proxy there gives me the link in the picture below. Im afraid thats not the service the widget uses. So my question is what client secret and id to use? Or should i somehow change the service used by the widget? Code below.

Best regards 

Config file:

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
 mustMatch="false">
 <serverUrls>
 <serverUrl url="http://services.arcgisonline.com"
 matchAll="true"/>
 <serverUrl url="route.arcgis.com"
 clientId="***"
 clientSecret="***"
 matchAll="true"/>
 
 </serverUrls>
</ProxyConfig>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Example Javascript:

 <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/widgets/Directions",
      "esri/core/urlUtils",
      "dojo/domReady!"
    ], function(
      Map,
      MapView,
      Directions,
      urlUtils) {

      // Proxy the route requests to avoid prompt for log in
      urlUtils.addProxyRule({
        urlPrefix: "route.arcgis.com",
        proxyUrl: "/DotNet/proxy.ashx"
      });

      var map = new Map({
        basemap: "topo-vector"
      });

      var view = new MapView({
        scale: 123456789,
        container: "viewDiv",
        map: map
      });

      var directionsWidget = new Directions({
        view: view
      });

      // Add the Directions widget to the top right corner of the view
      view.ui.add(directionsWidget, {
        position: "top-right"
      });
    });
  </script>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
MichaelLodes2
Occasional Contributor

Got it working now. I'm not to sure what the problem was, but it was in the proxy.config file. Using the code below made it work.

 

Config file:

 

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
 mustMatch="false">
 <serverUrls>
 <serverUrl url="https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"
 clientId="***"
 clientSecret="***"
 matchAll="true"/>
 
 </serverUrls>
</ProxyConfig>

So i removed: 

<serverUrl url="http://services.arcgisonline.com"
matchAll="true"/>

And changed the url to "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World ". I'm sure though that i tried this url before. Anyway it's working now and this thead can be closed. Thanks for the help.

0 Kudos