In a widget we need to be able to grab the UserID of the user currently logged in to the app (e.g. assuming they have signed in via AGOL or Portal), and then pass this userID as a string input parameter to another web service. Is this possible? Any ideas on how we can access current userID?
We have previously been using Geocortex Essentials and Workflow Designer, and there was a "GetCurrentUser" activity that made this very easy to do, and I was hoping there might be something like this that can be used in a Widget?
Thanks for any feedback/ideas.
For reference, I have already looked at following threads relating to securing applications to try to better understand how authentication works for Web Apps made with WAB Dev Edition (though am still digesting the material to make sense...):
You can use the singleton IdentityManager for this.
Add IdentityManager to your widget and access credentials through this:
You probably will want to add some checks to see if user is signed in as well.
Herdis Gudbrandsdottir, thank you for pointing us in right direction! We will test this out.
For checking to see if the user is signed in or not, it looks like we would use the checksigninstatus method, correct?
IdentityManager supports accessing resources on systems secured using ArcGIS tokens, OAuth, network authentication (e.g., Integrated Windows Authentication [IWA]), and client certificates. This includes secure resources hosted by ArcGIS for Server, Portal for ArcGIS, and ArcGIS Online. A set of classes is derived from Esri.ArcGISRuntime.Security.Credential to reference different types of security protocols. These include ArcGISTokenCredential, OAuthTokenCredential, ArcGISNetworkCredential, and CertificateCredential. During a challenge, use CredentialRequestInfo.AuthenicationType to determine the type of credential to create or return.
but I could not tell if this description was specific only to the the support provided by the .NET runtime?
I would take a look at esri.arcgis.Portal and getPortalUser() for cases where user is signed in using IWA:
And yes checkSignInStatus(resUrl) would be the correct way to get hold of the credential object