Load secured private layer with app login

1323
6
04-04-2019 08:22 AM
RubyStroschein
New Contributor III

Hello,

I'm developing angular/ruby on rails web application. For arcgis we are using javascript api. Is it possible to access private layers hosted on arcgis online with app id.

Layer.fromPortalItem({ portalItem: { // autocasts new PortalItem() id: "8444e275037549c1acab02d2626daaee" } }).then(function(layer){ // add the layer to the map map.add(layer); });

Tags (1)
0 Kudos
6 Replies
Noah-Sager
Esri Regular Contributor

Hi Rudy, absolutely. See this page on app logins and using a proxy:

https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/#app-login

RubyStroschein
New Contributor III

Hello Noah,

Thanks for reply. Do you have some sample code? Can I login using proxy?

This is stated in documentation:

App login can be used to access any of these services:

There are certain limitations and restrictions using app login.

Capabilities table

CapabilityApp login[3]Named user login [1]
Geocoding [2]
Routing [2]
Demographic data [2]
Premium layers and imagery [2]
Elevation analysis [2]
Spatial analysis [2]
Read public content
Read content owned by user
Read content shared with user [2]
Create/update/delete user's content
Create/update/delete shared content [2]
Share content with other users [2]

[1] Usage (if any) billed to a user's organization.

0 Kudos
Noah-Sager
Esri Regular Contributor

Hmmm, I guess you're not allowed to app logins for private layers/services. Well, you're certainly allowed to use the Esri resource proxy for this use case.

RubyStroschein
New Contributor III

Thanks I intend to try this. Can printtask service work with layers that go trough proxy?

0 Kudos
Noah-Sager
Esri Regular Contributor

Yes, this should work fine. You may need to host your own printing service though.

RubyStroschein
New Contributor III

We managed to access protected layer using arcgis toke, it is easier to use than proxy.

$http.get('/esri_layer/token').success(function (resp) {
w.IdentityManager.registerToken({
  server: url,
  token: resp.access_token,
  expires: resp.expires,
  ssl: true
});

Can printing service be used with Arcgis online developer account.

It seams that print service is not working properly for examples, they are failing to generate print

https://developers.arcgis.com/javascript/latest/sample-code/widgets-print/index.html

0 Kudos