I'm attempting to overwrite a hosted layer that I own in ArcGIS Online using the arcgis.features.FeatureLayerCollection.manager.overwrite() method in Python. When I login to AGOL normally it redirects me to my organization's sign-in page so I'm using OAuth2.0 to authenticate in Python. When using my client_id and client_secret I can read my hosted layers but I'm unable to overwrite them. When attempting the below code I receive a 403 Error.
from arcgis.gis import GIS
from IPython.display import display
import os
import glob
import pandas as pd
directory = r'G:/Shared drives/path/'
file_pattern = '*.csv'
latest_file = max(glob.glob(os.path.join(directory, file_pattern)), key=os.path.getctime)
df = pd.read_csv(latest_file)
from arcgis.features import FeatureLayerCollection
gis = GIS("https://myorg.maps.arcgis.com", client_id = "xyz", client_secret = "xyz" )
fs = gis.content.get('XXXXXXXXXXXXXXXXX')
fs = FeatureLayerCollection.fromitem(fs)
fs.manager.overwrite(df)The feature layer also has editing enabled. Is it possible to overwrite or even publish a hosted feature layer using OAuth2.0 in ArcGIS API Python?