How to use ArcGIS Online subscriber content in a 4.12 JS public app

746
7
09-25-2019 10:30 AM
JayHill
Occasional Contributor II

Everything I have read looks to relate to AGOL apps and not a custom deployed 4.12 app.

0 Kudos
7 Replies
JayHill
Occasional Contributor II

I assume a request interceptor is needed to add it the imageryserver url. Where do I generate the token then?

0 Kudos
Noah-Sager
Esri Regular Contributor

Hi Jay, you might want to review our docs about working with the ArcGIS Platform, and about accessing secure resources:

Working with the ArcGIS Platform | ArcGIS API for JavaScript 4.12 

Access secure resources | ArcGIS API for JavaScript 4.12 

0 Kudos
JayHill
Occasional Contributor II

Thanks Noah. I have been looking at those and, I'm sure I am overlooking something, everything I have read is describing the process to use it with a AGOL App. I need a custom app built in 4.12 to use subscriber content. 

0 Kudos
Noah-Sager
Esri Regular Contributor

This workflow is specific to a custom JS API application. Requires making a registered app on AGO or via the Developer's site, and adding the relevant code to your app.

Working with the ArcGIS Platform | ArcGIS API for JavaScript 4.12 

This sample uses a service proxy to access a premium service from AGO.

Directions widget | ArcGIS API for JavaScript 4.12 

Sample using OAuth as recommended in the previous guide topics.

Access ArcGIS Online items using OAuthentication | ArcGIS API for JavaScript 4.12 

You can also use a proxy to access secure services, from AGO and other Servers.

Proxy pages with the API | ArcGIS API for JavaScript 4.12 

0 Kudos
JayHill
Occasional Contributor II

Noah

I got it working by using the URL from the subscriber content and adding a new item from web in my own AGO content. When I pasted the URL it prompted me for credentials and I chose to store them in the service. I then shared that new item in my AGO. Is this not a secure or recommended workflow? 

0 Kudos
Noah-Sager
Esri Regular Contributor

Well, maybe it's fine. Is the new item in your AGO private or public? If it's public, I would be concerned that anyone could stumble across a link to that AGO item that consumes content that (presumably) requires credits.

0 Kudos
JayHill
Occasional Contributor II

Sure. I understand that. I'll keep an eye on it and see. I was more concerned with storing credentials in the service.  Thanks for the quick replies!

0 Kudos