Authenticating to use organization webmap

184
2
09-24-2021 04:57 AM
ThomasMoe
New Contributor

Hi,

I am writing a simple WPF application to view a webmap that is only available for my organization. I have had issues finding example code for how to authenticate to be able to do that. I have used the examples I have found, but cannot make it work. Any ideas? This is what I have so far.

 

private async Task SetupMap()
{
Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey = "*****";

ArcGISPortal portal = await ArcGISPortal.CreateAsync();

PortalItem mapItem = await PortalItem.CreateAsync(portal, "****");

Map map = new Map(mapItem);

this.Map = map;

}

 

 

Tags (2)
0 Kudos
2 Replies
ZackAllen
Esri Contributor
Hi Thomas, thanks for reaching out.

We have several samples that use authentication in WPF. You may have already seen our OAuth sample.

Before creating the ArcGIS Portal, you will need to set the challenge handler for the Authentication manager. We cover that workflow in this helper class.

Alternatively, you can create a portal using a Credential. This might be useful if you have already handled the user login and have the Credential.

Just to confirm, are you using ArcGIS Online? Also what type of authentication are you using in your app?

I hope this helps you fix your issue. Please let me know if you have more questions about this.
Zack
0 Kudos
ThomasMoe
New Contributor

Thank you for the reply. I am using ArcGis Online as far as I know :) I am using a set username and password for the application, and then authenticating that way.

I have also been looking into using a proxy to do all the hand-shaking, but I am also not sure how to implement a proxy into the application.

 

I will try and figure it out from your reply, and will post an update with code to how its going :)

 

Thank you :)

0 Kudos