Select to view content in your preferred language

Can you pass parameters to an add-in via an arcgis-pro:// URI?

1083
5
12-08-2022 12:36 AM
MikeDavlantes
Occasional Contributor
The AGOL/Portal OAuth window redirects you back to Pro using a URI kind of like this: arcgis-pro://auth/4428/
 
Is there any way to use a similar URI to handle custom actions within an ArcGIS Pro add-in?
 
Two adjacent use cases I am trying to tackle:
  1. Add-in authentication via a web service pretty much exactly how AGOL does it: click button on the add-in, a browser window opens, you enter your credentials, and you're redirected back to Pro with an auth token that the add-in can access.
  2. Sharing custom scenarios amongst users via URI schemes. For example, you have the add-in configured in a specific way and it has an item open. You want to message me this exact scenario for me to review. You send me a URI like this and Pro passes this data to my add-in: arcgis-pro://custom_add_in_name/?<scenario_data_goes_here>
Tags (3)
0 Kudos
5 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

For first case I use scenario like in code below:

                var psi = new ProcessStartInfo
                {
                    FileName = loginUrl,
                    UseShellExecute = true
                };

                // Open the browser.
                Process proc = Process.Start(psi);
                if (proc != null)
                {
                    // Wait For Login logic using HttpListenerContext
				....
                    // Get Tokens logic using HttpPost
				....
                }

Waiting for login or getting tokens are system dependent tasks. So I can suggest only c# classes to use in those tasks.

0 Kudos
MikeDavlantes
Occasional Contributor

Thanks! It makes sense that this would be a system thing and not an Arc thing. I think this will probably solve use case number 1.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

 

Or you can use the 'built-in' functionality of ArcGIS Pro to create a connection to the portal and then use the ArcGISPortal class to get a token:  ArcGISPortal Class—ArcGIS Pro

You can also use EsriHttpClient Class—ArcGIS Pro for you rest type calls and you don't need to worry about the token (expiration etc.)

0 Kudos
MikeDavlantes
Occasional Contributor

Unfortunately I am not connecting to Portal or AGOL, I only used those as examples of how I am hoping to get OAuth to work with my add-in. I will be connecting to our third-party server and running auth through there.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Back at the DevSummit 2017 an Esri Product Engineer (Tushar, he's no longer with esri) did a sample that pretty much does what you're trying to do in your use case 1.   Start at minute 37 of the video: ArcGIS Pro SDK for .NET: Integration with ArcGIS Online - Esri Videos: GIS, Events, ArcGIS Products ...

I attached the demo source code for your reference.  Please note that the code is for ArcGIS Pro 1.4 and about 5 years old.  However, it might provide you with some hints on how to possible use EsriHttpClient to accomplish your task.