How to make JavaScript API show company specific portal login screen when trying to access secure layer

01-20-2023 01:37 PM
New Contributor

Dear fellow developers,

I have written a webapp with the ArcGIS JavaScript API and all is working fine. Now I am trying to add secured layers to the web app and the app starts asking for credentials via a default login screen. I could use that, just entering username and password, but most users don't know their user name and password for ArcGIS. 



The company has implemented SSO with ArcGIS so users don't have to fill in their credentials. Users typically go to the main site and get to a company specific login screen where they have the option to click this SSO button.



My question; how can I make the JavaScript API show this company specific login page with SSO button instead of the default one?

I tried registering oauthInfo and serverInfo setting but without success....

Did anybody else ever built this?

Tags (3)
0 Kudos
1 Reply
Occasional Contributor III

This does require oAuth and you need to register your app with your Portal/AGO instance. Once you register it you get the app id and add it to your oAuth configuration in your app.


var oauthInfo;
//get oauthInfo
oauthInfo = new OAuthInfo({
appId: <app id here>,
portalUrl: <portal url here>,
popup: true



Then, when you load your secure layer you pass in the portal you are accessing it from...if it's a secured layer the login dialog will popup for that portal:


portalItem: {
// autocasts as new PortalItem()
id: <item id here>,
portal: new.Portal({ url: <portal or ago url here> });

.then(function (layer) {



Hope that helps!