Select to view content in your preferred language

Not able to Access Feature Layers

1089
3
Jump to solution
10-31-2022 06:39 AM
TheGamer
Regular Contributor

I have multiple feature layers being hosted on my account (share setting is set to owner).  I cannot see any of the layers. I have implemented the esriConfig.apikey into my code but I'm not able to access the layers

Charanb_0-1667232182613.png

 

@JeffreyWilkerson 

 

 

0 Kudos
1 Solution

Accepted Solutions
LaurenBoyd
Esri Contributor

Hi @TheGamer -

Sounds like you have an ArcGIS Online account and API keys cannot be used to access secure content with this account type. This is outlined in the note section: https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/#access-cont...

That means you must use OAuth 2.0 to authenticate your application with user logins to access your secure data. Here's the JS API documentation on how to implement this with OAuth 2.0: https://developers.arcgis.com/javascript/latest/secure-resources/#user-logins 

The OAuth information needs to be registered with the IdentityManager in your application. Here's a sample showing how to set up this workflow: https://developers.arcgis.com/javascript/latest/sample-code/identity-oauth-basic/ 

Lauren

View solution in original post

0 Kudos
3 Replies
LaurenBoyd
Esri Contributor

Hi @TheGamer -

Did you configure your API key to access those layers or webmap? This needs to be done explicitly in the API key settings. Here is the documentation outlining the details on accessing layers and webmaps via API keys: https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/#access-cont... 

There is also a tutorial that shows you how to configure your API key to access specific data: https://developers.arcgis.com/documentation/mapping-apis-and-services/security/tutorials/create-and-... 

Hope this helps!

Lauren
0 Kudos
TheGamer
Regular Contributor

Hi @LaurenBoyd when I got to Content and Items its asking me to create an application with OAuth2.0. I created the application but I'm not sure what to do next

Charanb_0-1667235832360.png

 

0 Kudos
LaurenBoyd
Esri Contributor

Hi @TheGamer -

Sounds like you have an ArcGIS Online account and API keys cannot be used to access secure content with this account type. This is outlined in the note section: https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/#access-cont...

That means you must use OAuth 2.0 to authenticate your application with user logins to access your secure data. Here's the JS API documentation on how to implement this with OAuth 2.0: https://developers.arcgis.com/javascript/latest/secure-resources/#user-logins 

The OAuth information needs to be registered with the IdentityManager in your application. Here's a sample showing how to set up this workflow: https://developers.arcgis.com/javascript/latest/sample-code/identity-oauth-basic/ 

Lauren
0 Kudos