Hi,
I am trying to use the Urban API with Python but I got an authentification error:
GraphQL query failed with 1 errors
[{'message': 'The access token provided is invalid or expired.', 'extensions': {'code': 'UNAUTHENTICATED'}}]
Im not sure why the token I provided to the urban api url is not working because it was generated using arcpy like below:
import arcpy from sgqlc.operation import Operation from sgqlc.endpoint.http import HTTPEndpoint from urban_api_schema import urban_api_schema as schema arcpy.SignInToPortal("https://www.arcgis.com", "myUserName", "MyPasswOrd") #token is generated correctly token = arcpy.GetSigninToken() urban_api_url = "https://urban-api.arcgis.com/graphql" + '?token=' + token['token'] endpoint = HTTPEndpoint(urban_api_url) #here it's the function that call the api to update the parcels for parcel_chunk in parcels_chunks: op = Operation(schema.Mutation) create_parcels = op.create_parcels(urban_database_id="1c80e3e815594fd288d347e132138f0a", parcels=parcel_chunk) create_parcels.attributes.__fields__('global_id') json_data = endpoint(op) errors = json_data.get('errors') if errors: print(errors)
Any helps would be greatly appreciated!
Thanks,
Maxime Demers
Solved! Go to Solution.
Yes ok, it can be deleted. Thank you for the feedback. Have a good day.
Further readings make me realize that I must use a OAuth2.0 authentification method.
Hi @MaximeDemers and thank you for reaching out to us. You are right, the Urban API does use OAuth2.0 authentication method. Does it mean that your question above is no longer valid?
Yes ok, it can be deleted. Thank you for the feedback. Have a good day.