Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add credentials to ServiceFeatureTable #1271

Open
delaney31 opened this issue Jul 20, 2023 · 1 comment
Open

Cannot add credentials to ServiceFeatureTable #1271

delaney31 opened this issue Jul 20, 2023 · 1 comment

Comments

@delaney31
Copy link

delaney31 commented Jul 20, 2023

I'm using Esri.ArcGISRuntime for .net6 in my MAUI application and I can no longer set the credentials for a ServiceFeatureTable like I could in Xamarin. The Credential property is gone. (Old Code below)

  var ParcelFeatureTable = new ServiceFeatureTable(parcelServiceLayerURI);
                    ParcelFeatureTable.Credential = cred;

How do I set the credentials for a ServiceFeatureTable?

@jnery
Copy link

jnery commented Aug 2, 2024

You can still use the authentication challenge handler. This will be triggered on table load. In the handler, you would be able to check info.ServiceUri before you assign the appropriate username/password. This credential will be added to the cache so it will be used for the next query or for any loadable objects that belong to the same server/portal.

AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async (info) =>
{
    return await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, username, password);
});

Or if you have a set of pre-defined credentials, you can generate them once and add them to the credential cache.

 var credential = await AuthenticationManager.Current.GenerateCredentialAsync(new Uri(portalUrl), username, password);
AuthenticationManager.Current.AddCredential(credential);

You can also look at .NET Maui OAuth sample and how the ArcGISLoginPrompt handles authentication challenge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants