Get Server Info using ArcGIS Runtime

347
2
01-19-2023 07:48 AM
MadsHoumann
New Contributor II

Is there an ArcGIS Runtime API for getting server info?

Rest endpoint: https://developers.arcgis.com/rest/services-reference/enterprise/server-info.htm 

For instance populating Esri.ArcGISRuntime.Security.ServerInfo given the server Uri?

Using ArcGIS Runtime 100.15 for .NET

Tags (2)
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor

Generally the runtime will auto-discover these for you. The exception is OAuth where you need to provide some of that info up front (like client id etc), but again most of it is loaded for you once you hit that server.

What is the reason you're needing the server info?

0 Kudos
MadsHoumann
New Contributor II

Actually I was thinking of a workaround for AuthenticationManager not providing the correct OAuth authorization URLs.

We have a portal with Azure AD authentication and a federated server.

ArcGIS Server service:
https://myserver.company.com/servermm/rest/services/MyService

Federated to portal with AAD auth set up:
https://myserver.company.com/portal

IOAuthAuthorizeHandler.AuthorizeAsync gets called with with:
serviceUri = https://myserver.company.com/servermm/rest/services/MyService
authorizeUri = https://myserver.company.com/servermm/rest/sharing/oauth2/authorize
callbackUri = https://myserver.company.com/servermm/rest/sharing/oauth2/approval

But that doesn't work - since it needs to go via the portal, so it ought to be:
authorizeUri = https://myserver.company.com/portal/sharing/oauth2/authorize
callbackUri = https://myserver.company.com/portal/sharing/oauth2/approval

As far as I could see (using ILSpy), AuthenticationManager tries to guess the authorization url, rather than using server info (owning system).

I've tried calling AuthenticationManager.Current.RegisterServer(serverInfo) with manually supplied ServerInfo.OwningSystemUri. But I still can't get it working.

So for now I've resorted to patching the authorizeUri and callbackUri so they hit the portal instead, and then it works.

The server info endpoint: https://myserver.company.com/servermm/rest/info
seems to provide the correct/expected owningSystemUrl and tokenServicesUrl values.

I've based the OAuth handler code on an Esri sample:
https://github.com/Esri/arcgis-runtime-samples-dotnet/tree/main/src/WPF/ArcGISRuntime.WPF.Viewer/Sam...

0 Kudos