Select to view content in your preferred language

Programmatically login to portal using SSO

53
1
yesterday
BerendVeldkamp
Frequent Contributor

I'm writing a (.NET) application that accesses a portal, configured for SSO.

I would like to login the current user without going through the login window at https://example.com/portal/sharing/oauth2/authorize , where you have the option to choose between AD login and ArcGIS login. Is this possible? I tried:

var url = "https://example.com/portal/sharing/rest/community/self?f=json";

var handler = new HttpClientHandler() { UseDefaultCredentials = true };
using var httpClient = new HttpClient(handler);

var json = await httpClient.GetAsync(url);
var responseBody = await json.Content.ReadAsStringAsync();

 

but this returns:

{"error":{"code":400,"messageCode":"COM_0019","message":"Not logged in.","details":[]}}

 

Or should I somehow request an access token with the default credentials? I can't find anything in the docs.

0 Kudos
1 Reply
John-Foster
Esri Contributor

Can you use the Maps SDK for .NET and then this becomes easier to handle

https://developers.arcgis.com/net/security-and-authentication/implement-authentication/

 

--jf
0 Kudos