Closed angus-s-mitchell closed 1 year ago
@angus-s-mitchell , I would try to pass the client_secret. You can check how in my issue https://github.com/Esri/arcgis-python-api/issues/1374
But right now, as you can see here : "https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/", This won't work in a script workflow.
Long history short, if you pass only client_id, it will prompt an input and redirect you to auth page. If you pass the client_secret, it will work and you will have acess to some routes, but not all, you might need to do others configs in developers page.
@hildermesmedeiros, I'm not seeking to run this code as part of a script workflow. I'm simply trying to use the intended oauth2 functionality as described in the guide you linked - "https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/". As you can see in the output I posted, I successfully authenticate (according to the guide, printing properties.user.username is how we confirm authentication.) If this is the case, the issue is separate to the initial authorisation - when content.add is called, we get a requests connection error.
@angus-s-mitchell
The type is not correctly set, it needs to be set to 'Image' since 'TIF' is not a type of service.
gis = GIS(profile="your_online_profile")
gis.content.add(
{"type": "Image", "title": "test_tif", "tags": ["tif", "test"]},
data=r"C:\ipython_workfolder\workspace\at3_1m4_01.tif",
)
To see a list of service types refer to: https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm
Hope this helps :)
I'm unable to secure a connection when adding content. I'm using oauth2, and can print correct username to verify it has authenticated correctly. I've followed existing setup instruction - authough the oauth2 authentication instructions were lacking, as they did not indicate I needed to use my own institution's login URL, but I figured that out eventually.
In the code and output below, I've removed identifying details, replacing with "< tags >"
My short python code is:
The output I get it:
I'm working in python 3.10.6. In case it provides any extra clarity, here is the python environment I'm working in.