Skip to content
B2B GroupPartner API

IP allowlist

A client can be locked to the addresses your servers call from. With a lock, a stolen client secret or token is useless outside your network.

How it works

  • The allowlist belongs to the client. You edit it in the developer portal. An empty list means no lock.

  • Entries are IPv4 or IPv6 addresses, or networks in CIDR notation:

    203.0.113.10
    198.51.100.0/24
    2001:db8:1234::/48
    
  • The list is checked twice: when you request a token, and on every call with the token. A change to the list applies to new tokens; request a new token after you change it.

  • A call from an address outside the list answers 403 ip_not_allowed. On the token route this only happens when the credentials are correct, so the answer never reveals whether a client exists.

  • The check fails closed: with a list, a request whose address cannot be determined is rejected.

Which address to allow

We see the public address your request leaves your network from - not your server's internal address. If your servers call through a NAT gateway, a proxy or a firewall, allow that device's public address.

To find it, call any site that echoes the caller's address from the server that will call us, for example:

curl -s https://ifconfig.me

Allow every address your traffic can leave from, including a secondary line or a failover gateway.

Testing the lock

Test in the sandbox with a sandbox client:

  1. Set the allowlist to an address that is not yours and request a token - expect 403 ip_not_allowed.
  2. Set it to your address, request a token again - expect 200.
  3. Call a route from another machine with that token - expect 403 ip_not_allowed.

curl

curl -s -o /dev/null -w "%{http_code}\n" https://api-sandbox.b2bgroup.dk/v1/oauth/token \
  -d grant_type=client_credentials -d client_id="$CLIENT_ID" -d client_secret="$CLIENT_SECRET"

C#

var response = await http.GetAsync("/v1/codes/ABC-7K3Q-M8ZP/status");
if (response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
    var error = await response.Content.ReadFromJsonAsync<JsonElement>();
    // error.GetProperty("error").GetString() is "ip_not_allowed" or "insufficient_scope".
}

Node

const response = await fetch(`${baseUrl}/v1/codes/ABC-7K3Q-M8ZP/status`, { headers });
if (response.status === 403) {
  const { error } = await response.json(); // 'ip_not_allowed' or 'insufficient_scope'
}

Python

response = session.get(f"{BASE_URL}/v1/codes/ABC-7K3Q-M8ZP/status")
if response.status_code == 403:
    error = response.json()["error"]  # "ip_not_allowed" or "insufficient_scope"

A 403 can mean two things; always look at error to tell a missing scope from a blocked address.