Issues with Credentials and Collaborations

798
12
01-21-2021 07:16 AM
Vidar
by
Occasional Contributor

Hi

Here is the scenario (I have written it as a basic story just to make it easier to envisage the problem):

We have some content stored in our company AGOL account (lets call this company Blue Company Ltd) , in a group with permissions given to it with the following credentials:

  • FooUser 
  • FooSecretPassword

Another company (called Red Company Ltd) - would really like to see this data in Blue Company's AGOL via their Enterprise Portal by using a collaboration. Both companies agree the collaboration and everything is sweet.

Blue Company also says, use this add-in to add our data in from our AGOL, it's got lots of nice tools to allow you to search for data and other exciting things.

A user in Red Company, called Billy, opens Pro and signs into Red Company enterprise portal, he also uses the add-in provided by Blue Company - he can see the data that is shared by Blue Company in the add-in and he tries to add it to the map.

😡Now Billy is mad, because when he tries to add the data, it prompts him for credentials for AGOL that only Blue Company knows about and they forgot to tell him and they didn't realise that they missed out that whole bit of functionality anyway! How embarrassing!

Billy complains to Blue Company about this  and the developers frantically try to find in a solution to Billy's problem.

....so there are 2 main questions:

1. In the Pro SDK can you code in the credentials before you try to add data into the map (from a group in AGOL which is shared in a collaboration)? This would be nice, in order to save the user having to remember the credentials every time they want to add data/use the add-in, especially if its been a while between sessions (I appreciate there is some long lived token here or something).

2. The credentials that you are prompted for are stored in Pro somewhere, in a token or cookie or something, and I have no idea how to reset that.  I would like to test my code as if the user has used the add-in for the first time and is trying to add data also for the first time.  How can I do this?

 

Code example 

The following is where I envisage any credential info going (perhaps?) when I try to add data from portal:

public static async Task AddLayer(string layerId)
{
    FeatureLayer featureLayer = null; Item testLayer = ItemFactory.Instance.Create(layerId, ItemFactory.ItemType.PortalItem);
await QueuedTask.Run(() =>{
    if (LayerFactory.Instance.CanCreateLayerFrom(testLayer))
    {
        featureLayer = LayerFactory.Instance.CreateLayer(testLayer, MapView.Active.Map, 0) as FeatureLayer; }
    else
    {
         log.Error($"Failed to add layer {layerId}");
    }
});

return featureLayer;

}
12 Replies
Vidar
by
Occasional Contributor

Thats a shame - is there something we can do to get this functionality exposed? It's a bit of a roadblock currently for my addin as I don't think having the OAuth prompt dialog is a nice user experience.

0 Kudos
KirkKuykendall1
Occasional Contributor III

I'm not sure, but it seems like Nearmap has this figured out.

After step 8 in their doc:

Select Store credentials with service item. This will store the ArcGIS Online credentials in the Portal and allow all Portal users to access the item without having to be signed into ArcGIS Online.

 

Vidar
by
Occasional Contributor

Thanks Kirk - it looks like it might be what we want but sadly I don't think this will work in our case. Its just frustrating that I am finding roadblocks when coding with this limited API - I knew this would happen after being spoiled with ArcObjects.

 

 

0 Kudos