API
Oauth

Partner Authentication

Your API keys carry many privileges, so be sure to keep them secure. Don't share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

Authentication to the API is performed with Bearer Auth (opens in a new tab).

curl --location 'https://api.sg.g17.eco/v1/oauth/token' \
--header 'Content-Type: application/json' \
--data '{
  "grant_type": "client_credentials",
  "client_id":  "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET"
}'

You must make all API calls over HTTPS. Calls that you make over plain HTTP will fail. API requests without authentication will also fail.

On success response, you should receive a token and userId associated with partner service account

{
  "access_token":"eyJhbGciOiJIUzI1NiIsIn...Ko1K2f_xV-3Azc2Tbr-xzpR_6qOOM-XM",
  "expires_in":86400,
  "token_type":"Bearer"
}

Example Header: Authorization: Bearer eyJhbGciOiJ.......iIuCqt0ujzOvWPVeCWjAW5Ea2cMnr9CTw

Current Authentication Details

Use the endpoint to check the authentication type and details of the user or partner connection

Partner Connection

curl --location 'https://api.sg.g17.eco/v1' \
--header 'Authorization: Bearer TOKEN_HERE'

Response will contain

{
    "success": true,
    "data": {
        "user": {
            "_id": "615dd5c551a6965f9408bfff",
            "firstName": "Service",
            "surname": "Account",
            "active": true
        },
        "connection": {
            "scopes": [],
            "roles": ["data_entry"],
            "addonId": "65084329e47e525360eb0116"
        },
        "type": "service_account"
    }
}

User API Key

{
    "success": true,
    "data": {
        "user": {
            "_id": "615dd5c551a6965f9408bfff",
            "firstName": "User A",
            "surname": "User A Surname",
            "active": true
        },
        "connection": {
            "scopes": [],
            "roles": ["data_entry"],
            "initiativeId": "6711c1f63a35b273a7998854",
            "apiKeyId": "67b417230660c52a5c17a1b6",
            "shortToken": "pa6DtsSXv5"
        },
        "type": "api_key"
    }
}