Get User from MapService Login

307
4
04-04-2017 09:17 AM
jaykapalczynski
Frequent Contributor

Is there a way to capture the User Name when the user is prompted to add their credentials for a secured service?  I want to write the user name to a variable in Javascript

Reply
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay,

   The help docs are your friend:

IdentityManager | API Reference | ArcGIS API for JavaScript 3.20 

IdentityManager.credentials[0].userId

KenBuja
MVP Honored Contributor

From this OAuth sample: OAuth Basic | ArcGIS API for JavaScript 3.20 

The variable "portalUser" contains the "userName" property. You can examine all the properties by opening up the developer tools in your browser and put a breakpoint at line 118.

jaykapalczynski
Frequent Contributor

Bit confused here and want to make sure we are on the same page. 

I have a simple Javascript app that I wrote.  Nothing is pointing to to ArcGIS online, but rather one of my own Map Services which prompts the user for credentials.  When they enter those and the app opens I want to write UserName to a variable.

Reply
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay,

  That is what the line of code and like I provided are for.