I am trying to use the GenerateToken endpoint to generate a token for my AGOL user account, from which I can subsequently perform a GET request on a FeatureLayer that is hosted in AGOL and shared with my user account.
I'm successfully receiving a token from the following URL via POST request as indicated via docs
https://www.arcgis.com/sharing/generateToken/?f=json&username=<MY_AGOL_USERNAME>&password=<MY_AGOL_P...
I then try to perform a GET request for my FeatureLayer, using the URL below and passing through the token I received from the previous POST
https://services1.arcgis.com/<HIDDEN>/arcgis/rest/services/<FEATURE_LAYER_NAME>/FeatureServer?f=json...
Unfortunately the response is {"error":{"code":498,"message":"Invalid token.","details":["Invalid token."]}}
I can confirm that I have permission to view the FeatureLayer, as I can log into AGOL via the same credentials and view the feature layer. When I click view, AGOL generates it's own token and if I was to use that token via
The expiry time of the token being returned is 2 hours from my current time.
Am I correct in assuming the token returned via /GenerateToken should enable me to perform GET requests on FeatureLayers/Services?
I'm not sure what else to try as there is minimal information in the error code.
Note: I cannot use the oAuth2 process here, hence using GenerateToken. Reason why is I'm writing some python scripts to automate some processing of data, and I need to have user credentials hard coded into the scripts.