I am creating a WPF application and I am using the simple example online at Display map | ArcGIS Maps SDK for .NET | ArcGIS Developers
If I do not specify an API key then it displays a blank window with Powered by ESRI.
If I specify an API KEY using this code then it displays a map as in the example.
public MainWindow()
{
InitializeComponent();/Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey = "AAPKa6a58defb24a41.............dj6-9WIzn5QX_ECKPq52HH8";
}
In my case I am wanting to use OKTA (SAML) authentication to connect to an ARCGIS enterprise system. I have this working using the following code.
ArcGISRuntimeEnvironment.Initialize((options) => { });
string serverUrl = "https://portal.domain.com/portal/";
var clientId = "8qOp0LS.......WwhZ6R";
var serverInfo = new ServerInfo(new Uri(serverUrl))
{
OAuthClientInfo = new OAuthClientInfo(clientId, new Uri(@"vmsUI://auth"), ""),
TokenAuthenticationType = TokenAuthenticationType.OAuthAuthorizationCode
};
AuthenticationManager.Current.RegisterServer(serverInfo);
AuthenticationManager.Current.OAuthAuthorizeHandler = new OAuthAuthorise();
var currentToken = (OAuthTokenCredential)AuthenticationManager.Current.FindCredential(new Uri(serverUrl), AuthenticationType.Token);
if (currentToken == null)
{
currentToken = (OAuthTokenCredential)await Task.Run(async () => await AuthenticationManager.Current.GenerateCredentialAsync(new Uri(serverUrl)), CancellationToken.None);
AuthenticationManager.Current.AddCredential(currentToken);
var portal = await Esri.ArcGISRuntime.Portal.ArcGISPortal.CreateAsync(new Uri(serverUrl), false);
var licenseInfo = await portal.GetLicenseInfoAsync();
var licenseResult = ArcGISRuntimeEnvironment.SetLicense(licenseInfo);
}
In my case the licenseResult returns a property of LicenseStatus: Valid
I can call ArcGISRuntimeEnvironemnt.GetLicense() and it returns the following
If I look at ArcGISRuntimeEnvironment.ApiKey it is set to ""
No map is displayed.
In the output window I see
ArcGIS Maps SDK: Load Error: Basemap
Esri.ArcGISRuntime.Http.ArcGISWebException
Token Required.
ArcGIS Maps SDK: Load Error: Map
Esri.ArcGISRuntime.Http.ArcGISWebException
Token Required.
So finally my question is what do I need to do to get this to work - I must be missing a step with a token but I do not know what.
Chris