Select to view content in your preferred language

"Token" property does not work for FeatureLayer

1734
2
05-30-2018 02:19 AM
deleted-user-OOe4JK-9Abnm
Deactivated User

Hi,

I need to add feature layer to a map.

My code:

this.props.mapView.map.add(
new FeatureLayer({
url: Config.layerUrl,
token: this.props.token
})
);

Problem 1: TypeScript returns the following error: "'token' does not exist in type 'FeatureLayerProperties'." I checked the type definition @types/arcgis-js-api@4.7.0, it is not defined, but 'token' exists in the documentation: FeatureLayer | API Reference | ArcGIS API for JavaScript 4.7 

Ok, I added type for 'token' on my own, but then we have problem 2...

Problem 2: The 'token' will not be sendt to the server. So I get a login dialog to be authenticated.

My question is how to add a featureLayer to the map by using token?

Tags (2)
0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor

According to the doc the recommended approach is to use IdentityManager.registerToken()

FeatureLayer | API Reference | ArcGIS API for JavaScript 4.7 

Also take a look at the Application logins section of the 'Access Secure Resources' guide topic for details on using a proxy. 

Using secure resources | ArcGIS API for JavaScript 4.7 

0 Kudos
deleted-user-OOe4JK-9Abnm
Deactivated User

Thank you, Kelly!!!

I did as you suggested. Added IdentityManager at the start of the app and the token was sent to the server when it needed.

IdentityManager.registerToken({
'token': token.value
});

But I still wondering why you have "token" as String in the documentation? It did not work for me. It is not even defined in types (typescript) for 4.7. Is IdentityManager only way it works?

0 Kudos