Current Setup:
I have a connection to our ArcGIS Enterprise Portal (on-prem) using the Add ArcGIS Server Layer
connection in QGIS. I have created an Desktop Application Item in the portal and I can connect using OAuth in QGIS to access the feature layers. The layer I am accessing in QGIS is an hosted feature layer (from Survey123) with attachments. I would like to show the attachments in the layer popup when clicking on a feature in QGIS.
Problem:
The problem is that in QGIS the attachments are not sent per default via the REST Api when requesting the data of a feature.
How I would like to solve this:
- Access the token stored internally in QGIS after OAuth
- Use an
HTML Widget
in theAttribute Form
and make a REST call to the feature service to request all attachments / images. - Display the images within the HTML Widget
Currently I am stuck reading the token from the QgsApplication.authManager()
.
My code so far - unfortunately this only gives me the connection details but not the token:
authMgr = QgsApplication.authManager()
success, decrypted_config = authMgr.loadAuthenticationConfig(
'791l69i', # the id of the existing configuration to load (7 chars)
QgsAuthMethodConfig(), # a fresh new config object
full=True, # whether to decrypt the credentials
)
if success:
print(decrypted_config.configMap())