Hello.
I am having trouble bypassing the identity manager login screen in Arcgis Maps SDK for JavaScript 4.28 version.
To summarize; In Arcgis js api 3.x versions, I could view an encrypted rest service on the arcgis server thanks to the token value I obtained. (For applications created by arcgis web app builder developer edition)
For this process, I obtain tokens using the POST method on the Arcgis server with the user information I obtained from the custom login screen, and then use the esriId.registerToken function and save the login information in json format into local storage.
When directed back to the application, I can use the credentials and serverInfos information in the local storage and bypass the identitymanager login screen with the esriId.initialize function.
(Reference: https://developers.arcgis.com/javascript/3/jssamples/widget_identitymanager_client_side.html)
Get Token
var tokenvalue = $.ajax({
type: "POST",
url: generatetokenaddress,
data: {
username: username,
password: password,
client: "referer&requestip",
referer: locationaddress,
expiration: '60',
f: "json"
},
dataType: "json"
}).done(function (response)
Register Token
if (response.token) {
IdentityManager.registerToken({
server: restserviceaddresss,
token: response.token,
expires: response.expires,
ssl: false,
userId: username
});
};
Set Local Storage
if (response.token !== undefined) {
var idString = JSON.stringify(IdentityManager.toJson());
if (supports_local_storage()) {
window.localStorage.setItem(cred, idString);
Example of data in local storage for 3.x:
{
"serverInfos": [
{
"server": "https://domain/arcgis",
"tokenServiceUrl": {
"promise": {},
"_pendingDfd": {
"promise": {},
"ioArgs": {
"args": {
"url": "https://domain/arcgis/rest/info",
"content": {
"f": "json"
},
"handleAs": "json",
"callbackParamName": "callback",
"timeout": 60000
},
"url": "https://domain/arcgis/rest/info?f=json",
"query": null,
"handleAs": "json",
"xhr": {}
}
},
"adminUrl_": "https://domain/arcgis/admin/generateToken"
},
"hasPortal": true
}
],
"oAuthInfos": [],
"credentials": [
{
"userId": "username",
"server": "https://domain/arcgis",
"token": "tokenvalue",
"expires": 1704892574229,
"ssl": false,
"creationTime": 1704888975210,
"scope": "server",
"resources": [
"https://domain/arcgis/rest/services/"
]
}
]
}
When I want to use the same scenario with the web application produced with Experience Builder Developer Edition, although it initializes the json data shown below and no error message occurs, the identity manager login screen is not bypassed and asks for user login again.
Get Token and register token codes are same like 3.x but configured for 4.28.
4.28 created credential json data in local storage for esriid.initialize:
{
"serverInfos": [
{
"adminTokenServiceUrl": "https://domain/arcgis/admin/generateToken",
"currentVersion": "10.7",
"hasPortal": false,
"server": "https://domain/arcgis",
"shortLivedTokenValidity": 60,
"tokenServiceUrl": "https://domain/arcgis/tokens/",
"webTierAuth": true
}
],
"oAuthInfos": [],
"credentials": [
{
"userId": "username",
"server": "https://domain/arcgis",
"token": "tokenvalue",
"expires": 1704892922005,
"ssl": false,
"creationTime": 1704889323452,
"scope": "server",
"resources": [
"https://domain/arcgis/rest/services/"
]
}
]
}
Thanks in advance for your help.
Server and portal info:
Arcgis Enterprise Server 10.7 (not federated and active directory connection available for user management)
Arcgis Enterprise Portal 10.7 for web map. (the web map used is publicly available)