The oauth2 application is created by me (DemersM) from the dashboard in developers.arcgis.com
I use the Client ID and Client Secret from that oauth2 application above to get a token like this:
import requests
from sgqlc.operation import Operation
from sgqlc.endpoint.http import HTTPEndpoint
from . import urban_api_schema as schema
def get_client_oauth2_token(portal_url, client_id, client_secret):
url = "{}/sharing/rest/oauth2/token".format(portal_url)
params = {
'client_id': client_id,
'grant_type': "client_credentials",
'client_secret': client_secret
}
r = requests.post(url, params=params, verify=True)
return r.json()
def query_urban_design_db_projects(endpoint_url, urban_model_id, token):
endpoint = HTTPEndpoint(endpoint_url, {"Authorization": "Bearer " + token, "Content-type": "application/json", "Accept": "application/json"})
op = Operation(schema.Query)
projects = op.urban_model(urban_model_id=urban_model_id).urban_design_databases.projects(
paging={"limit": 100}
)
attributes = projects.attributes()
attributes.event_name()
result = endpoint(op)
errors = result.get("errors")
if errors:
raise Exception(errors)
return result
token = get_client_oauth2_token("https://www.arcgis.com", "my_client_id", "my_client_secret")["access_token"]
projects = query_urban_design_db_projects("https://urban-api.arcgis.com/graphql", "703144ba056e43e59f373b971431a562", token)
print(projects)
Thanks again for your help!