Obtain an access token
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://your-instance.seventhings.com/customer-api/v1/auth_token");
struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }");
CURLcode ret = curl_easy_perform(hnd);using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://your-instance.seventhings.com/customer-api/v1/auth_token"), Content = new StringContent("{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://your-instance.seventhings.com/customer-api/v1/auth_token"
payload := strings.NewReader("{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://your-instance.seventhings.com/customer-api/v1/auth_token")) .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }")) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }");Request request = new Request.Builder() .url("https://your-instance.seventhings.com/customer-api/v1/auth_token") .post(body) .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'POST', url: 'https://your-instance.seventhings.com/customer-api/v1/auth_token', headers: {'Content-Type': 'application/json'}, data: { username: 'your username', password: 'S3cR3tP4ßW0rD', client_id: 'hash456789012345678901234567890123456789', grant_type: 'password' }};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://your-instance.seventhings.com/customer-api/v1/auth_token';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"username":"your username","password":"S3cR3tP4ßW0rD","client_id":"hash456789012345678901234567890123456789","grant_type":"password"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")val body = RequestBody.create(mediaType, "{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }")val request = Request.Builder() .url("https://your-instance.seventhings.com/customer-api/v1/auth_token") .post(body) .addHeader("Content-Type", "application/json") .build()
val response = client.newCall(request).execute()<?php
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => "https://your-instance.seventhings.com/customer-api/v1/auth_token", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode([ 'username' => 'your username', 'password' => 'S3cR3tP4ßW0rD', 'client_id' => 'hash456789012345678901234567890123456789', 'grant_type' => 'password' ]), CURLOPT_HTTPHEADER => [ "Content-Type: application/json" ],]);
$response = curl_exec($curl);$err = curl_error($curl);
curl_close($curl);
if ($err) { echo "cURL Error #:" . $err;} else { echo $response;}<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://your-instance.seventhings.com/customer-api/v1/auth_token', [ 'body' => '{ "username": "your username", "password": "S3cR3tP4ßW0rD", "client_id": "hash456789012345678901234567890123456789", "grant_type": "password" }', 'headers' => [ 'Content-Type' => 'application/json', ],]);
echo $response->getBody();import http.client
conn = http.client.HTTPSConnection("your-instance.seventhings.com")
payload = "{ \"username\": \"your username\", \"password\": \"S3cR3tP4ßW0rD\", \"client_id\": \"hash456789012345678901234567890123456789\", \"grant_type\": \"password\" }"
headers = { 'Content-Type': "application/json" }
conn.request("POST", "/customer-api/v1/auth_token", payload, headers)
res = conn.getresponse()data = res.read()
print(data.decode("utf-8"))import requests
url = "https://your-instance.seventhings.com/customer-api/v1/auth_token"
payload = { "username": "your username", "password": "S3cR3tP4ßW0rD", "client_id": "hash456789012345678901234567890123456789", "grant_type": "password"}headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://your-instance.seventhings.com/customer-api/v1/auth_token";
let payload = json!({ "username": "your username", "password": "S3cR3tP4ßW0rD", "client_id": "hash456789012345678901234567890123456789", "grant_type": "password" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://your-instance.seventhings.com/customer-api/v1/auth_token \ --header 'Content-Type: application/json' \ --data '{ "username": "your username", "password": "S3cR3tP4ßW0rD", "client_id": "hash456789012345678901234567890123456789", "grant_type": "password" }'wget --quiet \ --method POST \ --header 'Content-Type: application/json' \ --body-data '{ "username": "your username", "password": "S3cR3tP4ßW0rD", "client_id": "hash456789012345678901234567890123456789", "grant_type": "password" }' \ --output-document \ - https://your-instance.seventhings.com/customer-api/v1/auth_tokenRequest Bodyrequired
Section titled “Request Bodyrequired”The login credentials for the web API.
object
Your login username for the web app.
Your secret password.
The client_id, request on request
Example
{ "username": "your username", "password": "S3cR3tP4ßW0rD", "client_id": "hash456789012345678901234567890123456789", "grant_type": "password"}The Request to retrieve a new OAuth-Token from a Refresh-Token.
object
Your refresh token.
The client_id, request on request
Example
{ "refresh_token": "2b57a8d37baf1ef3a436968da51149b2eddf7f0f", "client_id": "hash456789012345678901234567890123456789", "grant_type": "refresh_token"}The Request to retrieve a new OAuth-Token from an sso authorization code.
object
Example
azure-open-id-connectExample
webExample
0.AU4AvAfVR74TOEesr5NM0atDfD8q_1GyO...Example
sso_auth_codeYou must provide either username, password and grant_type “password” or refresh_token and grant_type “refresh_token”
object
Your login username for the web app.
Your secret password.
Your refresh token.
The client_id, request on request
The password grant type
Responses
Section titled “Responses”Success
A default OAuth2 with the Resource owner password credentials flow with some additional data.
object
The access token to authenticate all restricted routes.
The seconds until the token expires.
This API only supports bearer tokens currently.
The scope is currently not in use.
The refresh token is currently not in use.
The unique identifier of the authenticated user.
Example
{ "access_token": "e68f38c2dca2add6c5528e16d7a2b453371e5870", "expires_in": 3600, "token_type": "Bearer", "scope": null, "refresh_token": "2b57a8d37baf1ef3a436968da51149b2eddf7f0f", "user_id": 1}Request body is missing or invalid or request data is invalid.
Invalid username and password combination or refresh token
User is not allowed to login
Contains information on why the user is not allowed to login
object
LoginDeactivated- User is temporarily not allowed to loginBanned- User is bannedEmailUnconfirmed- User email is not confirmed yetInactive- User is not activatedOnlySSOLoginAllowed- User is sso user and only allowed to login with sso provider
Example
{ "detail": "LoginDeactivated"}Internal Server Error.

