I'm trying to access a protected feature service using the Maps SDK version 200.2, and would like to use an application login to do so.
My basic flow so far is this:
AuthenticationManager.Current.ChallengeHandler = new AppChallengeHandler();
var table = new ServiceFeatureTable(new Uri("https://example.com/arcgis/rest/services/Test/FeatureServer/0"));
await table.LoadAsync();
and
internal class AppChallengeHandler : IChallengeHandler
{
public async Task<Credential> CreateCredentialAsync(CredentialRequestInfo requestInfo)
{
var challengeRequest = new CredentialRequestInfo
{
GenerateTokenOptions = new GenerateTokenOptions
{
TokenAuthenticationType = TokenAuthenticationType.OAuthClientCredentials,
},
ServiceUri = new Uri("https://example.com/portal"),
};
var serverInfo = AuthenticationManager.Current.FindServerInfo(
new Uri("https://example.com/arcgis/rest"));
serverInfo.OAuthClientInfo = new OAuthClientInfo(
CLIENTID,
new Uri("https://example.com"),
CLIENTSECRET);
serverInfo.TokenAuthenticationType = TokenAuthenticationType.OAuthClientCredentials;
var creds = await AuthenticationManager.Current.GetCredentialAsync(challengeRequest, false);
if (creds == null)
{
throw new Exception("Not authorized");
}
return creds;
}
}
The call to LoadAsync triggers CreateCredentialsAsync, at which time a serverInfo object for the service is added to the AuthenticationManager.
However, the code just stops at GetCredentialsAsync, no exception, nothing in the output window of Visual Studio, no request to be seen in Fiddler.
Does anyone know how to do this?