createPersonalAccessToken
Create a Personal Access Token (PAT) for the currently authenticated user.
note
In order to use the API, you must already be authenticated. This means you either already have a personal access token created from the Point One Navigation webapp or you're executing this operation from the GraphQL playground.
This mutation is most useful for automating creation of a new PATs when an existing one is nearing expiry.
createPersonalAccessToken(
name: String!
description: String
role: TokenRole
expiryInDays: Int! = 365
): String!
Arguments
createPersonalAccessToken.name ● String! non-null scalar common
createPersonalAccessToken.description ● String scalar common
createPersonalAccessToken.role ● TokenRole enum personal-access-tokens
createPersonalAccessToken.expiryInDays ● Int! non-null scalar common
Type
String scalar common
The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
Code Samples
- cURL
- JavaScript
- Python
- Go
curl -X POST https://graphql.pointonenav.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"query": "mutation CreatePersonalAccessToken($name: String!, $role: TokenRole, $expiryInDays: Int!) { createPersonalAccessToken(name: $name, role: $role, expiryInDays: $expiryInDays) }",
"variables": {
"name": "My API Token",
"role": "ROLE_READ_WRITE",
"expiryInDays": 365
}
}'
const mutation = `
mutation CreatePersonalAccessToken($name: String!, $role: TokenRole, $expiryInDays: Int!) {
createPersonalAccessToken(name: $name, role: $role, expiryInDays: $expiryInDays)
}
`;
const variables = {
"name": "My API Token",
"role": "ROLE_READ_WRITE",
"expiryInDays": 365
};
const response = await fetch('https://graphql.pointonenav.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
body: JSON.stringify({
query: mutation,
variables: variables
})
});
const data = await response.json();
console.log(data);
import requests
import json
mutation = """
mutation CreatePersonalAccessToken($name: String!, $role: TokenRole, $expiryInDays: Int!) {
createPersonalAccessToken(name: $name, role: $role, expiryInDays: $expiryInDays)
}
"""
variables = {
"name": "My API Token",
"role": "ROLE_READ_WRITE",
"expiryInDays": 365
}
response = requests.post(
'https://graphql.pointonenav.com/graphql',
json={
'query': mutation,
'variables': variables
},
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
)
data = response.json()
print(json.dumps(data, indent=2))
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type GraphQLRequest struct {
Query string `json:"query"`
Variables interface{} `json:"variables"`
}
func main() {
mutation := `
mutation CreatePersonalAccessToken($name: String!, $role: TokenRole, $expiryInDays: Int!) {
createPersonalAccessToken(name: $name, role: $role, expiryInDays: $expiryInDays)
}`
variables := map[string]interface{}{
"name": "My API Token",
"role": "ROLE_READ_WRITE",
"expiryInDays": 365,
}
reqBody := GraphQLRequest{
Query: mutation,
Variables: variables,
}
jsonData, _ := json.Marshal(reqBody)
req, _ := http.NewRequest("POST", "https://graphql.pointonenav.com/graphql", bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}