R-ArcGIS / arcgislayers

ArcGIS Location Services
http://r.esri.com/arcgislayers/
Apache License 2.0
38 stars 9 forks source link

client auth cannot read org shared items #13

Closed mmachir closed 10 months ago

mmachir commented 1 year ago

get_layer() and get_all_layers() are failing on a non-public feature service - maybe the token isn't being passed to these functions?

Repro:

library(arcgis)

# set token
Sys.setenv("ARCGIS_TOKEN" = auth_client()[["access_token"]])

# access FeatureServer (shared to Org)
fsurl <- "https://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/Madagascar_points/FeatureServer"
ft_srv <- feature_server(fsurl)
ft_srv

# option to retrieve all layers
fs_list <- get_all_layers(ft_srv)
fs_list$layers
fs_list$tables

# define FeatureLayer
fl <- get_layer(ft_srv, 0)
fl

get_all_layers() and get_layer() both fail and raise this error: image

JosiahParry commented 1 year ago

This is not a bug. This is an issue with client authorization. There is something in there that we don't fully understand. Adjusting the title and labels accordingly.

set_auth_token(auth_code())
#> Enter code: .... redacted
#> Token set to environment variable `ARCGIS_TOKEN`
fsurl <- "https://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/Madagascar_points/FeatureServer"
ft_srv <- arc_open(fsurl)
ft_srv
#> <FeatureServer <1 layer, 0 tables>>
#> CRS: 3857
#> Capabilities: Create,Delete,Query,Update,Editing
#>   0: Madagascar_points (esriGeometryPoint)

set_auth_token(auth_client())
#> Token set to environment variable `ARCGIS_TOKEN`

ft_srv <- arc_open(fsurl)
#> Error: Status code: 403
#> Error GWM_0003: You do not have permissions to access this resource or perform this
    operation.
mmachir commented 1 year ago

Question about this: for min ship for a first release, should the package be able to read/write public data services in AGOL/Enterprise? or should it also work with Private/Org-shared/Group-shared services?

JosiahParry commented 10 months ago

Confirmed that client auth is not expected to be able to publish.