Quick Start
  • Quick Start
    • Account Setup
    • Start with the Portal
      • Log in to Dashboard
      • Uploads Overview
        • Upload a File
        • Upload a Folder
      • Get Files
      • Delete Files
    • Start with the API
      • Obtain an API Key
      • Obtain an Access Token
      • Use the Access Token
  • Developer Documentation
  • Concepts
    • What is dStor?
    • Why dStor?
    • dStor Components
      • Directories
      • Folders
      • Files
      • Billing
  • Paying for dStor
    • Overview
  • Storage Node Operation Guide
    • Storage Node Operation
      • Node Operator Requirements
      • Become a Node Operator
      • Storage Node Install Pre-prequirements
      • Create User to Install
      • Create Directory & Install dStor
      • More Useful Commands
      • How it Works
  • Social
Powered by GitBook
On this page
  1. Quick Start
  2. Start with the API

Obtain an Access Token

PreviousObtain an API KeyNextUse the Access Token

Last updated 2 years ago

To obtain an access token, you must send a request to the dStor Developer Token endpoint. The request should include your API key and the appropriate authentication parameters.

Note:

The endpoint for the Testing environment is:

https://api.testnet.dstor.cloud/v1/dev/temp-token

The endpoint for the Production environment is:

https://api.dstor.cloud/v1/dev/temp-token

To acquire a temporary token with an API key, send a GET request to the following endpoint:

You will need to add the following as headers:

"api-key": "your-api-key" // required (64 characters)
"x-expiration": 1664349827 // optional, defaults to one year

Below are code snippets to use for the dStor Testing environment.

curl --location 'https://api.testnet.dstor.cloud/v1/dev/temp-token' \
--header 'api-key: 5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92' \
--header 'x-expiration: 1677336539'
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.testnet.dstor.cloud/v1/dev/temp-token',
  'headers': {
    'api-key': '5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92',
    'x-expiration': '1677336539'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://api.testnet.dstor.cloud/v1/dev/temp-token"

payload={}
headers = {
  'api-key': '5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92',
  'x-expiration': '1677336539'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.testnet.dstor.cloud/v1/dev/temp-token"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("api-key", "5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92")
  req.Header.Add("x-expiration", "1677336539")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Below are code snippets to use for the dStor Production environment:

curl --location 'https://api.dstor.cloud/v1/dev/temp-token' \
--header 'api-key: 5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92' \
--header 'x-expiration: 1677336539'
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.dstor.cloud/v1/dev/temp-token',
  'headers': {
    'api-key': '5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92',
    'x-expiration': '1677336539'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://api.dstor.cloud/v1/dev/temp-token"

payload={}
headers = {
  'api-key': '5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92',
  'x-expiration': '1677336539'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.dstor.cloud/v1/dev/temp-token"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("api-key", "5xikF8a5wcJeqVrtQE8OffKvtR9qaRxPXXJAedhIiNFWJbNsGqsdPfJ5eDYY7n92")
  req.Header.Add("x-expiration", "1677336539")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Swagger

Your temporary access token identifies you to the api and allows you to make requests to dStor.

The parameters and responses can be found here:

https://api.dstor.cloud/v1​/dev​/temp-token
https://api.testnet.dstor.cloud/v1/docs/index.html#/Token/get_v1_dev_temp_token