Select to view content in your preferred language

ArcGIS JS Portal Login

1376
6
02-26-2022 02:27 AM
Wade
by
Occasional Contributor

When I set the portal, the layer is private in ArcGIS Enterprise, the login screen appears, how to log in it in the application?

require([
    "esri/config"
], function (
    esriConfig
) {
    esriConfig.portalUrl = "https://MyApp/portal/";
});

 

0 Kudos
6 Replies
GaryB
by
Occasional Contributor

Hi Wade, this link may help with what you are trying to do: https://developers.arcgis.com/javascript/latest/arcgis-organization-portals/

0 Kudos
Wade
by
Occasional Contributor

Hi GaryB

The document describes the ArcGIS Enterprise part, not very clear, is there a practical example?

0 Kudos
GaryB
by
Occasional Contributor

yes, I recall struggling with this a bit, try this:

let info = new OAuthInfo({appId: 'xxxxxxxxxxxxxxxx', portalUrl: 'https://my.portal.url/portal', popup: false})

esriId.registerOAuthInfos([info])

esriId.checkSignInStatus(info.portalUrl + '/sharing').then(function () {

    let portal = new Portal({url: 'https://my.portal.url/portal'})

    portal.authMode = 'immediate'

    portal.load().then(
        function () {
            console.log(portal.user.username + ' is now connected to the portal')
            // call my afterSuccessfulLogin function
        },
        function (error) {
            console.log("couldn't successfully load the portal")
        }
    )
})

 

Wade
by
Occasional Contributor

ArcGIS Enterprise can also create appId?

The current way is to use ArcGIS Server generate token for verification.

0 Kudos
Lerman
by
Frequent Contributor

Hello GaryB, I tested this method, but the user still needs to log in once. Is there a solution to build the identity information into the program without requiring the user to log in again? Thank you so much!

0 Kudos
Wade
by
Occasional Contributor

Hi @GaryB, I tested this method, but the user still needs to log in once.  Is there any example, using the token method, the user does not need to log in once ?

0 Kudos