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
input
: ObtainJSONWebTokenInput
-
Returns
Affiliate organization authentication¶
Affiliate organizations can obtain a kraken token by providing their organization secret key
to the obtainKrakenToken
mutation.
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));
});
Customer authentication¶
Customers can obtain a kraken token by providing their email
and password
to the obtainKrakenToken
mutation.
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));
});
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.
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));
});
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.