Accessing User Credentials - Experience Builder Developer Edition

03-15-2022 02:50 PM
New Contributor II

Hello all, I am trying to access the logged in user's credentials within an experience. Ideally, the username or user id would be used as part of a query on a layer.

I believe that I can get the credentials and set them as a global variable but cannot figure out how to access this information. I see that there is documentation about SessionManager but I am a relative newcomer to JS and am a bit lost.

Any help is greatly appreciated!

0 Kudos
2 Replies
Esri Contributor

If you create an import at the top of your tsx/ts file to getAppStore eg 

import { getAppStore } from 'jimu-core';


The you can make a call to get the state of the application, with

 let state = getAppStore().getState();

The state object has the details of the logged in user. eg



Occasional Contributor

Within a widget you can do:


This will give you an object with the current user's information. This object will be of type IUser