ArcGIS JS Portal Login

892
6
02-26-2022 02:27 AM
Wade
by
New Contributor III

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
New Contributor III

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
New Contributor III

Hi GaryB

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

0 Kudos
GaryB
by
New Contributor III

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
New Contributor III

ArcGIS Enterprise can also create appId?

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

0 Kudos
Lerman
by
Occasional 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
New Contributor III

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