const fetch = require('node-fetch')
const crypto = require('crypto')
const url = 'https://platform.stagetokensoft.com/graphql'
// access and secret keys obtained from your admin dashboard
const accessKey = 'your access key'
const secretKey = 'your secret key'
// create a signature for the request body
const createSignature = (body, timestamp, secretKey) => {
const text = timestamp + body
const hmac = crypto.createHmac('sha256', secretKey)
return hmac.digest('hex')
const getServerTime = async () => {
const body = JSON.stringify(request)
'Content-Type': 'application/json',
const res = await fetch(url, options)
const { data } = await res.json()
const run = async () => {
const timestamp = await getServerTime()
const body = JSON.stringify({ query: '{ currentUser { id email } }' })
const signature = createSignature(body, String(timestamp), secretKey)
// include signature and timestamp to request headers
'access-sign': signature,
'access-timestamp': timestamp,
'Content-Type': 'application/json',
const res = await fetch(url, options)
const { data } = await res.json()
console.log('data', data)