Avoid login popup

1541
2
07-03-2021 09:33 AM
jkumartry1980
New Contributor II

Hi All,

 

I am using custom base map into my application , but the application is prompting to enter the credentials. I want avoid the login window and pass the credentials in the code itself. Kindly suggest me the idea.

 

 

var baseMapLayer = new TileLayer({
url: <basemap URL> 
});
const customBasemap = new Basemap({
baseLayers: [baseMapLayer]
});
map = new Map({
basemap: customBasemap
});

 

 

jkumartry1980_0-1625329943265.png

 

Best Regards,

K.Jayakumar

0 Kudos
2 Replies
JethroLeevers
Occasional Contributor

Hi K,

I would suggest using a token in your code, you could use a proxy to call the generateToken rest endpoint on a portal.

https://developers.arcgis.com/rest/users-groups-and-items/generate-token.htm

You can then use this with the IdentityManager class (https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html)

IdentityManager.registerToken(authInfo);

 

Regards,

Jethro

0 Kudos
fenglinhan
New Contributor

hi JethroLeevers, by your method, i can avoid the login popup window. but in my app i am loading a imagelayer https://env1.arcgis.com/arcgis/rest/services/Sentinel2_10m_LandCover/ImageServer

the token will cause the layer cannot be loaded and gives a invalid token error.

this layer is a public access resource.

how to solve this problem?

0 Kudos