Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.89k stars 1.1k forks source link

Displaying web maps/feature layer views/feature layers using an API Key results in token error #1153

Closed gisfromscratch closed 2 years ago

gisfromscratch commented 2 years ago

Describe the bug Displaying web maps/feature layer views/feature layers using an API Key results in a token error. We created a bunch of web maps and feature layer views. Unluckily, we cannot display any of these using the map widget. But, when we try to query them, the features are returned correctly. Maybe there is an issue with the internally used JS API of the python module.

The error is shown in the browser console.

To Reproduce Steps to reproduce the behavior:

from arcgis.gis import GIS
from arcgis.features import FeatureLayer
from arcgis.mapping import WebMap
from configparser import ConfigParser
config = ConfigParser()
config.read('arcgis-online.env')
section_key = 'arcgis'
gis = GIS(api_key=config[section_key]['ARCGIS_API_KEY'])
webmap_item = gis.content.get(config[section_key]['WEBMAP_ID'])
WebMap(webmap_item)

error:

message: "Unable to generate token"
name: "request:server"
<prototype>: Object { constructor: c(a, b, e), toJSON: toJSON(), type: "error" }

Screenshots If applicable, add screenshots to help explain your problem.

Expected behavior The webmap should be displayed as expected.

Platform (please complete the following information):

Additional context

Package                            Version
---------------------------------- -------------------
absl-py                            0.13.0
alabaster                          0.7.12
anaconda-client                    1.7.2
anaconda-navigator                 1.10.0
anaconda-project                   0.8.3
AnyQt                              0.0.13
arcgis                             1.8.5
argh                               0.26.2
argon2-cffi                        20.1.0
asn1crypto                         1.4.0
astroid                            2.5
astropy                            4.0.2
astunparse                         1.6.3
async-generator                    1.10
atomicwrites                       1.4.0
attrs                              20.3.0
autopep8                           1.5.4
Babel                              2.8.1
backcall                           0.2.0
backports.functools-lru-cache      1.6.1
backports.shutil-get-terminal-size 1.0.0
backports.tempfile                 1.0
backports.weakref                  1.0.post1
baycomp                            1.0.2
beautifulsoup4                     4.9.3
bitarray                           1.6.1
bkcharts                           0.2
bleach                             3.2.1
blinker                            1.4
blis                               0.7.4
bokeh                              2.2.3
boto                               2.49.0
Bottleneck                         1.3.2
brotlipy                           0.7.0
CacheControl                       0.12.6
cachetools                         4.2.2
catalogue                          2.0.4
certifi                            2021.10.8
cffi                               1.14.0
chardet                            3.0.4
click                              7.1.2
click-plugins                      1.1.1
cligj                              0.7.2
cloudpickle                        1.6.0
clyent                             1.2.2
cmarkgfm                           0.4.2
colorama                           0.4.4
commonmark                         0.9.1
conda                              4.11.0
conda-build                        3.20.5
conda-package-handling             1.7.2
conda-verify                       3.4.2
contextlib2                        0.6.0.post1
coverage                           6.2
cryptography                       3.1.1
cssselect                          1.1.0
cycler                             0.10.0
cymem                              2.0.5
Cython                             0.29.21
cytoolz                            0.11.0
dask                               2.30.0
decorator                          4.4.2
defusedxml                         0.6.0
dictdiffer                         0.8.0
diff-match-patch                   20200713
distributed                        2.30.1
docutils                           0.16
en-core-web-sm                     3.1.0
entrypoints                        0.3
et-xmlfile                         1.0.1
fastcache                          1.1.0
feedfinder2                        0.0.4
feedparser                         6.0.2
filelock                           3.0.12
Fiona                              1.8.4
flake8                             3.8.4
Flask                              1.1.2
flatbuffers                        1.12
fsspec                             0.8.3
future                             0.18.2
gast                               0.4.0
GDAL                               2.3.3
gdelt                              0.1.10.6
geopandas                          0.6.1
gevent                             20.9.0
glob2                              0.7
gmpy2                              2.0.8
google-auth                        1.32.1
google-auth-oauthlib               0.4.4
google-pasta                       0.2.0
greenlet                           0.4.17
grpcio                             1.34.1
h11                                0.12.0
h2                                 3.2.0
h3                                 3.7.3
h5py                               3.1.0
HeapDict                           1.0.1
hpack                              3.0.0
html5lib                           1.1
httpcore                           0.13.3
httpx                              0.18.1
huggingface-hub                    0.0.12
hyperframe                         5.2.0
idna                               2.10
imageio                            2.9.0
imagesize                          1.2.0
importlib-metadata                 2.0.0
iniconfig                          1.1.1
intervaltree                       3.1.0
ipykernel                          5.3.4
ipython                            7.19.0
ipython-genutils                   0.2.0
ipywidgets                         7.5.1
isort                              5.6.4
itsdangerous                       1.1.0
jdcal                              1.4.1
jedi                               0.17.1
jeepney                            0.5.0
jieba3k                            0.35.1
Jinja2                             2.11.2
joblib                             0.17.0
json5                              0.9.5
jsonschema                         3.2.0
jupyter                            1.0.0
jupyter-client                     6.1.7
jupyter-console                    6.2.0
jupyter-core                       4.6.3
jupyterlab                         2.2.6
jupyterlab-pygments                0.1.2
jupyterlab-server                  1.2.0
keras-nightly                      2.5.0.dev2021032900
Keras-Preprocessing                1.1.2
keyring                            21.4.0
keyrings.alt                       4.0.2
kiwisolver                         1.3.0
lazy-object-proxy                  1.4.3
lerc                               2.2
libarchive-c                       2.9
llvmlite                           0.34.0
locket                             0.2.0
lockfile                           0.12.2
lxml                               4.6.1
Markdown                           3.3.4
MarkupSafe                         1.1.1
matplotlib                         3.3.2
mccabe                             0.6.1
memory-profiler                    0.58.0
mistune                            0.8.4
mkl-fft                            1.3.1
mkl-random                         1.2.2
mkl-service                        2.4.0
mock                               4.0.2
more-itertools                     8.6.0
mpmath                             1.1.0
msgpack                            1.0.0
multipledispatch                   0.6.0
munch                              2.5.0
murmurhash                         1.0.5
navigator-updater                  0.2.1
nbclient                           0.5.1
nbconvert                          6.0.7
nbformat                           5.0.8
nest-asyncio                       1.4.2
networkx                           2.5
newspaper3k                        0.2.8
nltk                               3.5
nose                               1.3.7
notebook                           6.1.4
ntlm-auth                          1.4.0
numba                              0.51.2
numexpr                            2.8.1
numpy                              1.21.2
numpydoc                           1.1.0
oauthlib                           3.1.0
olefile                            0.46
openpyxl                           3.0.5
openTSNE                           0.4.3
opt-einsum                         3.3.0
orange-canvas-core                 0.1.15
orange-widget-base                 4.7.0
Orange3                            3.26.0
overpy                             0.6
packaging                          21.0
pandas                             1.1.3
pandocfilters                      1.4.3
parso                              0.7.0
partd                              1.1.0
path                               15.0.0
pathlib2                           2.3.5
pathtools                          0.1.2
pathy                              0.6.0
patsy                              0.5.1
pep8                               1.7.1
pexpect                            4.8.0
pickleshare                        0.7.5
Pillow                             8.0.1
pip                                21.0.1
pkginfo                            1.6.1
pluggy                             0.13.1
ply                                3.11
preshed                            3.0.5
prometheus-client                  0.8.0
prompt-toolkit                     3.0.8
protobuf                           3.17.3
psutil                             5.7.2
ptyprocess                         0.6.0
py                                 1.9.0
pyasn1                             0.4.8
pyasn1-modules                     0.2.8
pycodestyle                        2.6.0
pycosat                            0.6.3
pycparser                          2.20
pycurl                             7.43.0.5
pydantic                           1.8.2
pydocstyle                         5.1.1
pyflakes                           2.2.0
Pygments                           2.7.2
PyJWT                              1.7.1
pykerberos                         1.2.1
pylint                             2.6.0
pynndescent                        0.5.2
pyodbc                             4.0.0-unsupported
pyOpenSSL                          19.1.0
pyparsing                          2.4.7
pyproj                             1.9.6
pyqtgraph                          0.11.0
pyrsistent                         0.17.3
pyshp                              2.1.3
PySocks                            1.7.1
pytest                             0.0.0
pytest-cov                         3.0.0
python-dateutil                    2.8.1
python-jsonrpc-server              0.4.0
python-language-server             0.35.1
python-louvain                     0.15
pytz                               2020.1
PyWavelets                         1.1.1
pyxdg                              0.27
PyYAML                             5.3.1
pyzmq                              19.0.2
QDarkStyle                         2.8.1
QtAwesome                          1.0.1
qtconsole                          4.7.7
QtPy                               1.9.0
readme-renderer                    24.0
regex                              2021.4.4
requests                           2.24.0
requests-file                      1.5.1
requests-kerberos                  0.12.0
requests-ntlm                      1.1.0
requests-oauthlib                  1.3.0
requests-toolbelt                  0.9.1
rfc3986                            1.4.0
rope                               0.18.0
rsa                                4.7.2
Rtree                              0.9.4
ruamel-yaml                        0.15.87
sacremoses                         0.0.45
scikit-image                       0.17.2
scikit-learn                       0.23.2
scipy                              1.5.3
seaborn                            0.11.0
SecretStorage                      3.1.2
Send2Trash                         1.5.0
sentencepiece                      0.1.95
serverfiles                        0.3.1
setuptools                         50.3.1.post20201107
sgmllib3k                          1.0.0
Shapely                            1.6.4.post1
shiboken2                          5.15.2
simplegeneric                      0.8.1
singledispatch                     3.4.0.3
sip                                4.19.13
six                                1.15.0
smart-open                         5.1.0
sniffio                            1.2.0
snowballstemmer                    2.0.0
sortedcollections                  1.2.1
sortedcontainers                   2.2.2
soupsieve                          2.0.1
spacy                              3.1.0
spacy-legacy                       3.0.8
Sphinx                             3.2.1
sphinxcontrib-applehelp            1.0.2
sphinxcontrib-devhelp              1.0.2
sphinxcontrib-htmlhelp             1.0.3
sphinxcontrib-jsmath               1.0.1
sphinxcontrib-qthelp               1.0.3
sphinxcontrib-serializinghtml      1.1.4
sphinxcontrib-websupport           1.2.4
spyder                             4.1.5
spyder-kernels                     1.9.4
SQLAlchemy                         1.3.20
srsly                              2.4.1
statsmodels                        0.12.0
sympy                              1.6.2
tables                             3.6.1
tblib                              1.7.0
tensorboard                        2.5.0
tensorboard-data-server            0.6.1
tensorboard-plugin-wit             1.8.0
tensorflow-estimator               2.5.0
termcolor                          1.1.0
terminado                          0.9.1
testpath                           0.4.4
thinc                              8.0.7
threadpoolctl                      2.1.0
tifffile                           2020.10.1
tinysegmenter                      0.3
tldextract                         3.1.0
tokenizers                         0.10.3
toml                               0.10.1
toolz                              0.11.1
toposort                           1.6
torch                              1.9.0
torch-scatter                      2.0.9
tornado                            6.0.4
tqdm                               4.50.2
traitlets                          5.0.5
transformers                       4.8.2
twine                              0.0.0
typer                              0.3.2
typing-extensions                  3.7.4.3
ujson                              4.0.1
unicodecsv                         0.14.1
urllib3                            1.25.11
wasabi                             0.8.2
watchdog                           0.10.3
wcwidth                            0.2.5
webencodings                       0.5.1
Werkzeug                           1.0.1
wheel                              0.35.1
widgetsnbextension                 3.5.1
Wikidata                           0.7.0
wrapt                              1.12.1
wurlitzer                          2.0.1
xlrd                               1.2.0
XlsxWriter                         1.3.7
xlwt                               1.3.0
xmltodict                          0.12.0
yapf                               0.30.0
zict                               2.0.0
zipp                               3.4.0
zope.event                         4.5.0
zope.interface                     5.1.2
achapkowski commented 2 years ago

@gisfromscratch your version of the Python API is very old, please update to 2.0.0. Also the api_key does not give you permission to access the resource.

API key support was added at version 1.9.0.