Hello,
Im trying to bypass the IdentityManager in ReactJS and I dont know how to access to the registerToken function.
I made a custom login where i ask the user and pass and when through ajax i generated the token for that user.
The token is the localStorage.
But everytime that i tried to add a new layer to the map(feature in this case) the IdentitManager pop up shows up, so
¿is there a way to do it?
I already search in the forum but i cannot use the proxy option.
My code in js is the following (im not using amd).
import React from 'react';
import ReactDOM from 'react-dom';
import token from '../services/token-service';
import layers from '../services/layers-service';
/*FOR LOGIN APP*/
class Interruptions extends React.Component {
constructor(){
super();
this.onClick = this.onClick.bind(this);
// console.log('this is my token', token.read());
}
componentDidMount(){
var map = new esri.Map("myMapDiv", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
var esriId = esri.IdentityManager();
esriId.registerToken({
server: 'http://myserverWITHOUTwww/arcgis/rest',
userId: 'EXAMPLEUSER',
token: token.read(),
expires: 1440,
ssl: false
});
console.log(esriId.registerToken());
var myFirstLayer = new esri.layers.FeatureLayer(layers.read_layer_sed());
map.addLayer(myFirstLayer);
}
onClick(){
console.log(token.read());
}
render(){
return (
<div className="interruptions_wrapper">
<div className="searchBox">
<input className="searchBox__searchInput" ref="NIS" type="text" />
<input className="searchBox__searchSubmit" type="submit" onClick={this.onClick} />
</div>
<div className="myMapDiv" id="myMapDiv"></div>
</div>
);
}
}
ReactDOM.render(<Interruptions />, document.getElementById('myInterruptions'));
Solved! Go to Solution.
I fix my issue doing this:
var url="http://gisred.chilquinta.cl:5555/arcgis/rest/services/Interrupciones/PO/MapServer/0?f=json&token="+token.read();
where i have my singleton for all the urls
I fix my issue doing this:
var url="http://gisred.chilquinta.cl:5555/arcgis/rest/services/Interrupciones/PO/MapServer/0?f=json&token="+token.read();
where i have my singleton for all the urls