Skip to main content

Access token

To receive an access token and refresh token, the /auth route will be used.

The access token will have an expiration time of 15 minutes, however the refresh token will have a much longer expiration time.

The route will return an access token, token type, and refresh token.

Below are examples on using this route. More information on Authentication see here

Curl example

curl --header "Content-Type: application/json" \ --request POST \ --data '{"user_name": "user1234", "password": "password1234"}' \ https://quinix.byteconnect.us/auth

Python example

import requests
from os import getenv

username = getenv("username")
password = getenv("password")
body = {"username" : username, "password" : password}

url = getenv("bytefederal_api_url")

request = requests.post(f"{url}/auth", json=body)
response = request.json()
print(response)

NodeJS example

async function Auth() {
const username = process.env.USERNAME;
const password = process.env.PASSWORD;
const bodyData = {
username,
password
}
const url = `${process.env.BYTECONNECTURL}/auth`;
const request = await fetch(url, {
method: "POST",
body=JSON,stringify(bodyData),
headers: {
"Content-Type": "application/json"
}
}
);
const response = await request.json();
console.log(response);
}

HTTP Codes

200

Returns a JSON encoded response of an access token, the token type, and the refresh token.

401

Username or password was invalid.