Using Developer Tools
There are multiple developer tool IDEs such as Insomnia, Postman, and Altair. Here are examples using Insomnia and Postman.
Insomnia is an API request IDE and a remote.it plugin is available to assist with authentication to allow you to experiment before you develop code. For graphQL, you can explore the schema, generate queries and mutations. For the REST-API, you can create http requests.

Download and Install Insomnia

The API Design Platform and API Client
GetInsomnia
It is recommended that you install Insomnia Core rather than Insomnia Designer, but the plugin should work for both versions.

Add the Plugin to Insomnia

We will be using a remote.it provided plugin to create queries which will automatically sign the requests.
Go to preferences:
Enter insomnia-plugin-remoteit and click Install Plugin

Generate a graphQL Request

Make sure to create a POST request and select GraphQL Query as Body type. NOTE: All graphQL queries and mutations are made with POST
You can type a sample GraphQL query to https://api.remote.it/graphql/v1 like:
1
{
2
login {
3
email
4
}
5
}
Copied!
If you haven't already set up your machine with the credentials file, see here and do so now.
Select the Auth tab of the query and select Bearer Token authentication. Click on theToken field and CTRL+Spaceto select the remote.it API authentication tag, and select a specific profile otherwise the default profile will be used.
You now can send the request and execute the query using the credentials stored earlier.
If you want to start using the API requests in your code, you cannot use the generated code out of Insomnia as the generated signature is only good for that specific request. You will need to use the http request signing methodology. Some examples can be found on the authentication page.

Download and Install Postman

Postman
These instructions have been written using Version 9.0.5

Create a Remote.it Environment

You can quickly change postman environments for any request. All our required keys and headers will be stored here. Add and Save the values retrieved from your credentials file.
1
R3_ACCESS_KEY_ID
2
R3_SECRET_ACCESS_KEY
3
R3_DEVELOPER_API_KEY
Copied!

Create and Setup Request

Make sure to create a POST request and select Raw or GraphQL as the body type. NOTE: All graphQL queries and mutations are made with POST

Body

Pre-Request Script

Add the Pre-Request Script below to generate the needed environment variables for each request. This MUST be run prior to every request.
1
//Sign with Remote.it Http-Signature
2
const urlTool = require('url')
3
4
function computeHttpSignature(config, headerHash) {
5
let sig = 'Signature keyId="${keyId}",algorithm="${algorithm}",headers="${headers}",signature="${signature}"'
6
7
// compute sig here
8
let signingBase = ''
9
config.headers.forEach(function(h){
10
if (signingBase !== '') { signingBase += '\n' }
11
signingBase += h.toLowerCase() + ": " + headerHash[h]
12
})
13
14
const hashf = (function() {
15
switch (config.algorithm) {
16
case 'hmac-sha1': return CryptoJS.HmacSHA1
17
case 'hmac-sha256': return CryptoJS.HmacSHA256
18
case 'hmac-sha512': return CryptoJS.HmacSHA512
19
default : return null
20
}
21
}())
22
23
const hash = hashf(signingBase, config.secretkey)
24
const signatureOptions = {
25
keyId : config.keyId,
26
algorithm: config.algorithm,
27
headers: config.headers,
28
signature : CryptoJS.enc.Base64.stringify(hash)
29
}
30
31
// build sig string here
32
Object.keys(signatureOptions).forEach(function(key) {
33
var pattern = "${" + key + "}",
34
value = (typeof signatureOptions[key] != 'string') ? signatureOptions[key].join(' ') : signatureOptions[key]
35
sig = sig.replace(pattern, value)
36
})
37
return sig
38
}
39
40
//postman version 9.0.5 doesn't allow you get length of the body in all cases. Its dependent on the body 'mode' and computed at send request
41
function computeContentLength(mode, body){
42
switch (mode) {
43
case 'raw': {
44
if (body.raw == undefined) {
45
return 0
46
} else {
47
return Buffer.byteLength(body.raw)
48
49
}
50
}
51
case 'graphql': return Buffer.byteLength(getModifiedBody(body.graphql))
52
default : return 0
53
}
54
}
55
56
function getModifiedBody(body) {
57
let modifiedBody = {}
58
Object.keys(body).forEach(function (h) {
59
if (body[h] !== "" && body[h] !== 'undefined') modifiedBody[h]= body[h]
60
})
61
const modifiedBodyString = JSON.stringify(modifiedBody)
62
return modifiedBodyString
63
}
64
65
function replaceVariables(content) {
66
while(content.indexOf('{{') >= 0) {
67
const variableName = content.substring(content.indexOf('{{')+2, content.indexOf('}}'))
68
const variableValue= pm.environment.get(variableName) || pm.globals.get(variableName)
69
content = content.replace('{{'+variableName+'}}', variableValue)
70
}
71
return content
72
}
73
74
const url = replaceVariables(request.url)
75
const { hostname } = urlTool.parse(url)
76
const accessKey = pm.environment.get('R3_ACCESS_KEY_ID') || pm.globals.get('R3_ACCESS_KEY_ID')
77
const accessKeySecretPreParse = pm.environment.get("R3_SECRET_ACCESS_KEY") || pm.globals.get("R3_SECRET_ACCESS_KEY")
78
const accessKeySecret = CryptoJS.enc.Base64.parse(accessKeySecretPreParse)
79
const curDate = new Date().toGMTString()
80
const targetUrl = url.trim().replace(new RegExp('^https?://[^/]+/'),'/') // strip hostname
81
const method = request.method.toLowerCase()
82
const contentLength = computeContentLength(pm.request.body.mode, pm.request.body)
83
const contentType = 'application/json'
84
85
const headerHash = {
86
date : curDate,
87
'(request-target)' : method + ' ' + targetUrl,
88
'host' : hostname,
89
'content-type': contentType,
90
'content-length' : contentLength
91
}
92
const config = {
93
algorithm : 'hmac-sha256',
94
keyId : accessKey,
95
secretkey : accessKeySecret,
96
headers : [ '(request-target)', 'host','date', 'content-type', 'content-length' ]
97
}
98
const sig = computeHttpSignature(config, headerHash)
99
100
pm.request.headers.add({key: 'Authorization', value: sig})
101
pm.request.headers.add({key: 'Date', value: curDate})
102
pm.request.headers.add({key: 'content-length', value: contentLength})
103
pm.request.headers.add({key: 'content-type', value: contentType})
104
pm.request.headers.add({key: 'developerkey', value: '{{R3_DEVELOPER_API_KEY}}' })
Copied!

Send Request and review results

GraphQL
REST
Last modified 1mo ago