How to use an API token
Authenticate and run GraphQL queries with API tokens in GraphQL client, or PowerShell.
GraphQL clients
When using tools like Apollo Explorer, Postman, or any other GraphQL client, you must include the API token in the request header:
Authorization: Bearer ENTER_YOUR_API_TOKEN
Review Auth in GraphOS Studio for more information on how to include headers in Apollo Explorer.
PowerShell
In this section, you'll learn how to authenticate and execute GraphQL queries using PowerShell and the PSGraphQL module.
PSGraphQL automatically handles the POST request, JSON conversion, and response parsing.
-
Install the PSGraphQL module (if not already installed).
Install-Module -Name PSGraphQL -Scope CurrentUser -
Import the module.
Import-Module PSGraphQL -
Set the GraphQL endpoint and access token.
$uri = "[https://api.n-able.com/graphql](https://api.n-able.com/graphql)"$accessToken = "ENTER_YOUR_API_TOKEN"
Define the GraphQL query.
$query = @"
query {
customers {
customerId
customerName
devices {
siteName
deviceId
longName
deviceClass
}
}
}
"@ Set up headers for authentication.
$headers = @{
"Authorization" = "Bearer $accessToken"
} Execute the GraphQL query.
$response = Invoke-GraphQLQuery -Uri $uri -Query $query -Headers $headers
Updated 4 days ago
For further information on authentication and our API tokens visit: