My Maui app was previously using 200.8.1, and I'm updating it to use 300.0. I have a scenario where I want to sign in to a token-secured service which has an owning system.
The ServerInfo looked like this back in 200.8.1:
OAuthClientInfo: null
OwningSystemUri: {https://[abc].com/portal}
ServerUri: {https://[abc].com/arcgis/rest}
TokenAuthenticationType: ArcGISToken
TokenServiceUri: {https://[abc].com/portal/sharing/rest/generateToken}
and CredentialRequestInfo.ServiceUri is https://[abc].com/arcgis/rest/services/xyz/FeatureServer?f=json
But in 300.x, the CredentialRequestInfo.ServiceUri is the owning portal, https://[abc].com/portal. I know this is expected, as documented in the release notes:
CredentialRequestInfo.ServiceUri semantics changed: For federated services, it now contains the owning portal URL rather than the original service URL. For other services, it contains the resource path without query parameters.
The problem is, when I try to call AccessTokenCredential.CreateAsync with the owning portal uri, I get an ArcGISServerException: "Unable to generate token for this server".
The only way I can see to get the actual ServiceUri I need is to look at the CredentialRequestInfo.Error, which in this case is a TokenRequiredException, and extract the service uri from that… Is that the intended way to go about things?
I am creating the AccessTokenCredential from own IChallengeHandler implementation, but I did also try setting up the DefaultChallengeHandler instead and it has the same "unable to generate token" error…
(Note that just hardcoding the uri isn't an option because I may be loading arbitrary token-secured services.)