I am working on a .NET MAUI application that uses a secure webmap from Portal. I can authenticate the user successfully with the following code:
CredentialRequestInfo credentialRequestInfo = new()
{
AuthenticationType = AuthenticationType.Token,
ServiceUri = PortalURL,
GenerateTokenOptions = new()
{
TokenAuthenticationType = TokenAuthenticationType.OAuthAuthorizationCode,
TokenExpirationInterval = System.TimeSpan.MaxValue
}
};
OAuthTokenCredential credentialRequestResponse = (await AuthenticationManager.Current.ChallengeHandler.CreateCredentialAsync(credentialRequestInfo)) as OAuthTokenCredential;
AuthenticationManager.Current.AddCredential(credentialRequestResponse);
var arcgisPortal = await ArcGISPortal.CreateAsync(PortalURL);
I am then creating a web map based on a specific arcgisPortal above using the following code
PortalItem _mapItem = await PortalItem.CreateAsync(arcgisPortal, portalItemId);
The problem I'm running into is that because some of the layers in the webmap have an Organization-level sharing set, it is prompting me to log in AGAIN to load the webmap, which has a less restrictive sharing set ("Public" for Enterprise users on the network) Is there a specific flow or way to utilize the credentials within the AuthenticationManager to get those items without prompting the user to log in again?
It also appears that there is a separate credential being added after logging into the Webmap page. I am doing this through the AuthenticationManager.Current.Credentials object. The first item is the Service URI of the first credential. The second item is the Service URI after logging in on the web map
https://portalname.com/arcgis/
https://portalname.com/gisserver/rest/services/folder/item/MapServer?f=json
Because both these items are located within the same portal, is there a way to utilize the first credential to get data from the second endpoint? I'm trying to prevent the user from having to log in multiple times.