Select to view content in your preferred language

User authentication without hardcoding

1280
1
04-07-2017 12:05 PM
AlexandraYanick
New Contributor

Is there a way to request a users username and password for authentication/token, instead of hardcoding a username and password?  I found the example using the serverAuth code, but I would like to make sure the user has access to the map service?

0 Kudos
1 Reply
JohnGravois
Deactivated User

if you want to enable authentication with a standalone ArcGIS Server instance, you can consider creating your own sign in dialog with <input> elements and a <button> to give your users a chance to supply the credentials so that you can kick off a `/generateToken` request dynamically.

If the content is secured through ArcGIS Online (or an instance of ArcGIS Server federated with Portal) you can and should use OAuth2 instead of handling the user's credentials yourself. You can find an example of that below.

ArcGIS Online OAuth | Esri Leaflet