{"status": "true","token": "a1327b84435481d9048504f0e924f431","email": "someuser@remote.it","service_authhash": "E1F1772EA75D04755B8BBD236C470550E7A9FB33"}
{"status": "false","reason": "[0102] The username or password is invalid","code": "GENERAL_ERROR"}
You can get your developer key here.
#!/bin/shDEVKEY="your_developer_key"USERNAME="your_user_name"PASSWORD="your_password"curl -X POST -H developerkey:"$DEVKEY" -H Content-Type:application/json \-H Cache-Control:no-cache -d "{ \"username\":\"$USERNAME\", \\"password\":\"$PASSWORD\" }" https://api.remot3.it/apv/v27/user/login
This example uses the awesome Axios request library. To install, run npm install axios
.
const axios = require("axios");const developerkey = process.env.REMOTEIT_DEVELOPER_KEY;const username = process.env.REMOTEIT_USERNAME;const password = process.env.REMOTEIT_PASSWORD;axios.post("https://api.remot3.it/apv/v27/user/login",{ username, password },{ headers: { developerkey } }).then(response => {console.log("Status Code:", response.status);console.log("Body:", response.data);}).catch(error => {console.log(error);});
Save this to a file (say remoteit-login.js
), then run the following:
export REMOTEIT_DEVELOPER_KEY="...your developer key..."export REMOTEIT_USERNAME="...your remote.it username..."export REMOTEIT_PASSWORD="...your remote.it password..."node remoteit-login.js
Note: Make sure to put your developer key, remote.it username and password above.
import requestsimport jsonimport osheaders = {"developerkey": os.environ["REMOTEIT_DEVELOPER_KEY"]}body = {"password": os.environ["REMOTEIT_PASSWORD"],"username": os.environ["REMOTEIT_USERNAME"]}url = "https://api.remot3.it/apv/v27/user/login"response = requests.post(url, data=json.dumps(body), headers=headers)response_body = response.json()print("Status Code: %s" % response.status_code)print("Raw Response: %s" % response.raw)print("Body: %s" % response_body)
Save this to a file (say remoteit-login.py
), then run the following:
export REMOTEIT_DEVELOPER_KEY="...your developer key..."export REMOTEIT_USERNAME="...your remote.it username..."export REMOTEIT_PASSWORD="...your remote.it password..."python remoteit-login.py
Note: Make sure to put your developer key, remote.it username and password above.
using System;using System.Net.Http;using Newtonsoft.Json;using System.Collections.Generic;namespace remote.it_api_example{class Program{static void Main(string[] args){string jsonString = "";string url = "https://api.remot3.it/apv/v27/user/login";HttpClient client = new HttpClient();HttpRequestMessage requestData = new HttpRequestMessage();// Configure the HTTP requests's url, headers, and bodyrequestData.Method = HttpMethod.Post;requestData.RequestUri = new Uri(url);requestData.Headers.Add("developerkey", Environment.GetEnvironmentVariable("REMOTEIT_DEVELOPER_KEY"));Dictionary<string, string> bodyData = new Dictionary<string, string>() {{"password", Environment.GetEnvironmentVariable("REMOTEIT_PASSWORD") },{"username", Environment.GetEnvironmentVariable("REMOTEIT_USERNAME") }};string jsonFormattedBody = JsonConvert.SerializeObject(bodyData);requestData.Content = new StringContent(jsonFormattedBody);try{// Send the HTTP request and run the inner block upon recieveing a responsevar response = client.SendAsync(requestData).ContinueWith((taskMessage) =>{var result = taskMessage.Result;var jsonTask = result.Content.ReadAsStringAsync();jsonTask.Wait();// Store the body of API responsejsonString = jsonTask.Result;});response.Wait();}catch (HttpRequestException e){// Triggered when the API returns a non-200 response codejsonString = e.Message;}// Print JSON response from APIConsole.WriteLine(jsonString);}}}
<?php$ch = curl_init();curl_setopt_array($ch, array(CURLOPT_URL => "https://api.remot3.it/apv/v27/user/login",CURLOPT_HTTPHEADER => array("developerkey: ".$_ENV["REMOTEIT_DEVELOPER_KEY"]),CURLOPT_POSTFIELDS => json_encode(array("username" => $_ENV["REMOTEIT_USERNAME"],"password" => $_ENV["REMOTEIT_PASSWORD"])),CURLOPT_RETURNTRANSFER => true));$response = curl_exec($ch);$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);curl_close($ch);print("Status Code: ".$statusCode."\n");$responseData = json_decode($response);print_r($responseData);?>
Save this to a file (say remoteit-login.php
), then run the following:
export REMOTEIT_DEVELOPER_KEY="...your developer key..."export REMOTEIT_USERNAME="...your remote.it username..."export REMOTEIT_PASSWORD="...your remote.it password..."php remoteit-login.php