I have this code snip below.
The user Name and password are owner level permissions and have access to everything in our Enterprise... so im confused.
AND confused why line 21 returns NONE
The reson I am going this route is I need to increase the token expiration time... not sure how to do it any other way...
otherwise I would just do this
if portal_username == '' and portal_password == '':
gis = GIS(profile='Survey123_prof')
else:
gis = GIS(portal_url, portal_username, portal_password)
token = gis._con.token
item_object = gis.content.get(feature_layer_id)
ANY thoughts?
token_url = f"{portal_url}/sharing/rest/generateToken"
payload = {
"username": portal_username,
"password": portal_password,
"client": "referer",
"referer": portal_url,
"expiration": expiration_minutes,
"f": "json"
}
response = requests.post(token_url, data=payload)
token_data = response.json()
custom_token = token_data["token"]
print("custom token " + custom_token)
gis = GIS(url=portal_url, credentials={"token": custom_token})
print(f"Token successfully generated! Expires at timestamp: {token_data['expires']}")
tokenvalue = gis._con.token
print(tokenvalue)
item_object = gis.content.get(feature_layer_id)
print(item_object)