For the case where a third party needs to access measurements on a
supply point, the proper way to achieve this is by setting up an OAuth
Application for them on the support site. You will need the
OAUTH_MANAGER
permission to do this. API_ENGINEER
alone isn't
enough.
-
Access the [OAuth application page on the Support Site](https:///authentication/applications/).
-
Create application - filling out the application name as appropriate.
-
We want Confidential client for Client type. This should be the default.
-
SAVE THE SECRET KEY. This secret key is like a password. Kraken cannot retrieve this key, it can only give you a new key. The old key will not work once this occurs, and your clients will need to update their environment variables with this new key.
-
Select the Client credentials grant for the authorization grant type.
-
Leave the Allowed URIs blank, client credentials clients don't require this field.
-
Select
THIRD_PARTY_UTILITY_USAGE_DATA_VIEWER
as the API Role. -
Leave the skip authorization checkbox unchecked.
-
Your Application during setup should look like this.
-
Create the application and share the secret key in a secure way with the developers who need access to it.
-
Your application post setup should look like this. This is where you will get the client_id.
-
Make sure the permissions list is exactly the ones above. If they aren't, navigate to the [API Roles/Permissions config page](https:///api-roles-and-permissions/) to be sure that
THIRD_PARTY_UTILITY_USAGE_DATA_VIEWER
has theCAN_VIEW_DETAILED_USAGE
and theCAN_QUERY_PROPERTY
permissions associated with it. This API Role and these permissions are Kraken core objects, and your Kraken will already be able to use them; however, it's possible that your Kraken has not applied these permissions to this role yet. -
Share the application's
client_id
andsecret_key
with the devevelopers that need them. Once they have these and the permissions in step 12 are set, they can be granted a Kraken token and start getting measurements!
Receiving any output from most Kraken APIs will require a Kraken token
for access. Account Users are granted these tokens when they login with
their email and password. OAuth Applications will use the auth server's
/token/
REST endpoint. See the Python example below.
import requests
def print_token(client_id: str, client_secret: str):
response = requests.post(
"https://auth.octopus.energy/token/",
data={
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
},
)
tokens = response.json()
print(tokens["access_token"])
if __name__ == "__main__":
client_id = "auth_app_client_id_here"
client_secret = "auth_app_client_secret_here"
print_token(client_id, client_secret)
Once you have this token, you'll add it to your [API request](https://) in the headers tab like so. You may need to refresh this page if the GraphiQL interface is not loading.
{
"Authorization": "your-kraken-token-here"
}