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.
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.)
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.
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.
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 & Industries
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.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.