Skip to main content

Get User Scopes

This query retrieves user scopes and access permissions for the authenticated user. User scopes define which resources and data the current user can access within the Causely platform.

Prerequisite

This example reuses the helper utilities defined in the Authentication and GraphQL Clients sections—fetching an access token, creating the GraphQL client, and sending a request with the post_query wrapper (CLI, Python, or Go). Keep those helpers in scope before running this query.

import os

if __name__ == "__main__":
# Get credentials from environment
cid, secret = os.getenv("CAUSELY_CLIENT_ID"), os.getenv("CAUSELY_CLIENT_SECRET")
if not cid or not secret:
raise EnvironmentError("Missing CAUSELY_CLIENT_ID or CAUSELY_CLIENT_SECRET")

# Get access token and create GraphQL client
token = get_causely_access_token(cid, secret)
client = create_graphql_client(token)

# Prepare query variables
variables = {
"filter": {
"nameExpr": ""
}
}

# Execute the query
query = """
query getUserScopes($filter: UserScopeFilter, $first: Int, $after: String, $last: Int, $before: String) {
getUserScopes(
filter: $filter
first: $first
after: $after
last: $last
before: $before
) {
totalCount
edges {
node {
id
name
audience
ownerId
lastUpdate
scopes {
typeName
typeValues
__typename
}
__typename
}
cursor
__typename
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
totalCount
__typename
}
__typename
}
}
"""

result = post_query(client, query, variables)
print(result)