Skip to content

Authentication

Overview

In order to keep the Octopus Energy USA platform safe and secure, we require users to make authenticated calls to our APIs. Some endpoints do not require an authentication.

Authenticated APIs

We will be obtaining tokens using the obtainKrakenToken mutation. Each endpoint that requires authentication will have a similar admonition:

Authentication Required

Requires CAN_ACCESS_.... permission.

Arguments

Returns

mutation getKrakenToken($input: ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
    refreshExpiresIn
  }
}

Affiliate organization authentication

Affiliate organizations can obtain a kraken token by providing their organization secret key to the obtainKrakenToken mutation.

1
2
3
4
5
6
mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
  }
}
1
2
3
4
5
6
# Input variables
{
  "input":{
    "organizationSecretKey": "sk_live_52634d602c63dc3e1"
  }
}
import pprint

import requests

# API_URL = "https://api.oeus-kraken.energy/v1/graphql/" # Prod
API_URL = "https://api.oeus-kraken.systems/v1/graphql/" # Test
HEADERS = {}

MUTATION = """
mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
  }
}
"""

VARIABLES = {
    "input":{
        "organizationSecretKey": "sk_live_52634d602c63dc3e1"
    }
}

session = requests.Session()
response = session.post(
    url=API_URL,
    json={"query": MUTATION, "variables": VARIABLES}
)
pprint.pprint(response.json())
const axios = require("axios")

// const API_URL = "https://api.oeus-kraken.energy/v1/graphql/" // Prod
const apiUrl = "https://api.oeus-kraken.systems/v1/graphql/" // Test
let headers = {'content-type': 'application/json'}

const mutation = `
    mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
      obtainKrakenToken(input: $input) {
        token
        refreshToken
    }
}
`
const variables = {
        "input": {
            "organizationSecretKey": "sk_live_52634d602c63dc3e1"
    }
}

axios({
  url: apiUrl,
  method: 'post',
  data: {
    query: mutation,
    variables: variables
  },
  headers: headers
}).then((response) => {
  console.log(response.data)
});
import axios from 'axios';

// const API_URL = "https://api.oeus-kraken.energy/v1/graphql/" // Prod
export const apiUrl = "https://api.oeus-kraken.systems/v1/graphql/" // Test
let headers = {'content-type': 'application/json'}


export const query = `
  mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
    obtainKrakenToken(input: $input) {
      token
      refreshToken
    }
  }
`
export const variables = {
    "input": {
        "organizationSecretKey": "sk_live_52634d602c63dc3e1"
    }
}

axios({
  url: apiUrl,
  method: "post",
  data: {
    query: mutation,
    variables: variables,
  },
  headers: headers,
}).then((response) => {
  console.log(JSON.stringify(response.data, null, 4));
});
1
2
3
4
5
6
7
8
{
  "data": {
    "obtainKrakenToken": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiTYyNzQwNzkwNywidmlld2VyIjoia3Jha2VufGFjY291bnQtdXNlcjoyIiwic2NvcGUiOiJOL0EiLCJ0b2tlblVzZSI6ImlkIiwiaXNzIjoiaHR0cHM6Ly9hcGkub2V1cy1rcmFrZW4uZW5lcmd5L3YxL2dyYXBocWwvIiwiZ3R5IjoiRU1BSUwtQU5ELVBBU1NXT1JEIn0.FyQE5sx2vwj9VUTiGGCglHHbI9j3uOm9hrdm_4khiO4",
      "refreshToken": "5263440da611ad60289a5b88c3e9b567d39d829edfe11a31a8346187c63dc3e1"
    }
  }
}

Customer authentication

Customers can obtain a kraken token by providing their email and password to the obtainKrakenToken mutation.

1
2
3
4
5
6
mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
  }
}
1
2
3
4
5
6
7
# Input variables
{
  "input":{
    "email": "customer@example.com",
    "password": "StrongPassword123"
  }
}
import pprint

import requests

# API_URL = "https://api.oeus-kraken.energy/v1/graphql/" # Prod
API_URL = "https://api.oeus-kraken.systems/v1/graphql/" # Test
HEADERS = {}

MUTATION = """
mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
  }
}
"""

VARIABLES = {
  "input":{
    "email": "customer@example.com",
    "password": "StrongPassword123"
  }
}

session = requests.Session()
response = session.post(
    url=API_URL,
    json={"query": MUTATION, "variables": VARIABLES}
)
pprint.pprint(response.json())
const axios = require("axios")

// const API_URL = "https://api.oeus-kraken.energy/v1/graphql/" // Prod
const apiUrl = "https://api.oeus-kraken.systems/v1/graphql/" // Test
let headers = {'content-type': 'application/json'}

const mutation = `
    mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
      obtainKrakenToken(input: $input) {
        token
        refreshToken
    }
}
`
const variables = {
        "input": {
            "email": "customer@example.com",
            "password": "StrongPassword123"
    }
}

axios({
  url: apiUrl,
  method: 'post',
  data: {
    query: mutation,
    variables: variables
  },
  headers: headers
}).then((response) => {
  console.log(response.data)
});
import axios from 'axios';

// const API_URL = "https://api.oeus-kraken.energy/v1/graphql/" // Prod
export const apiUrl = "https://api.oeus-kraken.systems/v1/graphql/" // Test
let headers = {'content-type': 'application/json'}


export const query = `
  mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
    obtainKrakenToken(input: $input) {
      token
      refreshToken
    }
  }
`

export const variables = {
    "input": {
        "email": "customer@example.com",
        "password": "StrongPassword123"
    }
}

axios({
  url: apiUrl,
  method: "post",
  data: {
    query: mutation,
    variables: variables,
  },
  headers: headers,
}).then((response) => {
  console.log(JSON.stringify(response.data, null, 4));
});
1
2
3
4
5
6
7
8
{
  "data": {
    "obtainKrakenToken": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiTYyNzQwNzkwNywidmlld2VyIjoia3Jha2VufGFjY291bnQtdXNlcjoyIiwic2NvcGUiOiJOL0EiLCJ0b2tlblVzZSI6ImlkIiwiaXNzIjoiaHR0cHM6Ly9hcGkub2V1cy1rcmFrZW4uZW5lcmd5L3YxL2dyYXBocWwvIiwiZ3R5IjoiRU1BSUwtQU5ELVBBU1NXT1JEIn0.FyQE5sx2vwj9VUTiGGCglHHbI9j3uOm9hrdm_4khiO4",
      "refreshToken": "5263440da611ad60289a5b88c3e9b567d39d829edfe11a31a8346187c63dc3e1"
    }
  }
}

Refresh kraken token

Users can refresh their tokens by calling using the obtainKrakenToken mutation with the required credentials, or they can use their refreshToken to obtain a new token. The following is an example that uses the refreshToken to obtain a new token.

1
2
3
4
5
6
mutation refreshKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input:$input) {
    token
    refreshToken
  }
}
1
2
3
4
5
6
# Input variables
{
  "input":{
    "refreshToken": "5263440da611ad6028a31a8346187c63dc3e1"
  }
}
import pprint

import requests

# API_URL = "https://api.oeus-kraken.energy/v1/graphql/" # Prod
API_URL = "https://api.oeus-kraken.systems/v1/graphql/" # Test
HEADERS = {}

MUTATION = """
mutation refreshKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
  }
}
"""

VARIABLES = {
  "input":{
    "refreshToken": "5263440da611ad6028a31a8346187c63dc3e1",
  }
}

session = requests.Session()
response = session.post(
    url=API_URL,
    json={"query": MUTATION, "variables": VARIABLES}
)
pprint.pprint(response.json())
const axios = require("axios")

// const API_URL = "https://api.oeus-kraken.energy/v1/graphql/" // Prod
const apiUrl = "https://api.oeus-kraken.systems/v1/graphql/" // Test
let headers = {'content-type': 'application/json'}

const mutation = `
mutation refreshKrakenToken($input:ObtainJSONWebTokenInput!) {
  obtainKrakenToken(input: $input) {
    token
    refreshToken
  }
}
`
const variables = {
  "input":{
    "refreshToken": "5263440da611ad6028a31a8346187c63dc3e1",
  }
}

axios({
  url: apiUrl,
  method: 'post',
  data: {
    query: mutation,
    variables: variables
  },
  headers: headers
}).then((response) => {
  console.log(response.data)
});
import axios from 'axios';

// const API_URL = "https://api.oeus-kraken.energy/v1/graphql/" // Prod
export const apiUrl = "https://api.oeus-kraken.systems/v1/graphql/" // Test
let headers = {'content-type': 'application/json'}


export const query = `
  mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
    obtainKrakenToken(input: $input) {
      token
      refreshToken
    }
  }
`

export const variables = {
    "input": {
        "refreshToken": "5263440da611ad6028a31a8346187c63dc3e1"
    }
}

axios({
  url: apiUrl,
  method: "post",
  data: {
    query: mutation,
    variables: variables,
  },
  headers: headers,
}).then((response) => {
  console.log(JSON.stringify(response.data, null, 4));
});
1
2
3
4
5
6
7
8
{
  "data": {
    "obtainKrakenToken": {
      "token": "eyJ0ekgakgnvjanvlnabjobnakkghajbnkjnXAiOiEiLCJ0b2tlblVzZSI6ImlBBU1NXT13uOm9hrdm_4khiO4",
      "refreshToken": "123513425425355350da611ad60289a5b88c3e9b5678346187c63dc3e1"
    }
  }
}

Unauthenticated APIs

Some of our endpoints are public and they will have a similar admonition:

Authentication not required

name_of_the_endpoint does not require authentication.

Back to top