I need assistance with an interesting issue im experiencing when i try to automate the download process from agol to local drive. Im utilizing python3 to automate the download process, i can manually log in and manually download the fgdb of the data on agol. Once i attempt to do the same steps with the python script it fails when it attempts to download the data with an error code 403.
here is my script:
from time import strftime
print(strftime('%c'))
from arcgis.gis import GIS
#variables#
itemid = 'itemid number goes here'
output = r'C:\Temp\AGOLtest'
tempfile = strftime('Test_%m_%d_%y')
#variables for testing#
##itemid = 'testing itemid goes here'
##output = r'C:\Temp\AGOLtest'
##tempfile = strftime('Test_%m_%d_%y')
#file pull#
gis = GIS('URL', 'un', 'pw')
print(gis)
print('access to agol successful')
arcgisitem = gis.content.get(itemid)
print(arcgisitem)
print('access to agol item successful')
print(tempfile)
arcgisitem.export(tempfile, 'File Geodatabase', parameters=None, wait=True)
print(tempfile)
print('item export to agol complete')
myexport = gis.content.search(tempfile, item_type='File Geodatabase')
print('search for agol content item complete')
print(myexport)
print(myexport[0])
print(myexport[0].itemid)
fgdb = gis.content.get(myexport[0].itemid)
print('found fgdb export on agol content page')
fgdb.download(save_path=output)
print('export downloaded to folder location')
fgdb.delete()
print('export has been deleted from agol content page')
print('Script completed at {}'.format(strftime('%c')))