I used the ESRI Python token code sample, which returns a token.
However when I use the token in <url+token>, I get an error??
formatted_json = [feature['attributes'] for feature in raw_json['features']]
KeyError: 'features'
{'error': {'code': 498, 'message': 'Invalid Token', 'details': []}}
The code is:
ef get_token():
params = {'username': username, 'password': password, 'expiration': str(60), 'client': 'referer', 'referer': referer, 'grant_type': 'client_credentials', 'client_id': client_id, 'client_secret': client_secret, 'f': 'json'}
request = requests.get(token_url, params=params)
response = request.json()
#print(response)
token = response['access_token']
return token
portalToken = get_token()
#### THIS works + returns Token
#print(portalToken)
##print("END")
if __name__ == "__get_token__":
"""optional location for parameters"""
print(sys.argv[0]) The get_token returns a token.. they all seem to have .. at the end of the token?? This is really frustrating, would appreciate any pointers!!
Thanks,
Clive