Skip to content

Commit 2dcc5dd

Browse files
Niklas Hildebrandtclaude
authored andcommitted
fix(push,cdr): honor Receiver.raw_token and add CdrLocation.evse_uid
Two OCPI compliance/interop fixes needed for CDR push to eMSPs that do not base64-decode the auth token (e.g. DepotCharge): - push_object now sends the raw auth token when Receiver.raw_token=True, instead of always base64-encoding for 2.2.x/2.3.x. Some eMSPs compare the literal Token header value, so a base64-encoded token is rejected with 401 "Unknown token". - CdrLocation (2.2.1 and 2.3.0) now includes the spec-required evse_uid field. It was missing, so the lib silently dropped evse_uid from the serialized CDR, causing receivers to reject the push with 400. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9e0b141 commit 2dcc5dd

4 files changed

Lines changed: 4 additions & 1 deletion

File tree

ocpi/core/push.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def push_object(
123123
receiver_responses = []
124124
for receiver in push.receivers:
125125
# get client endpoints
126-
if version.value.startswith("2.1") or version.value.startswith("2.0"):
126+
if receiver.raw_token or version.value.startswith("2.1") or version.value.startswith("2.0"):
127127
token = receiver.auth_token
128128
else: # 2.2.x and 2.3.x use base64-encoded tokens
129129
token = encode_string_base64(receiver.auth_token)

ocpi/core/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class OCPIResponse(BaseModel):
2424
class Receiver(BaseModel):
2525
endpoints_url: URL
2626
auth_token: str
27+
raw_token: bool = False
2728

2829

2930
class Push(BaseModel):

ocpi/modules/cdrs/v_2_2_1/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CdrLocation(BaseModel):
7979
state: String(20) | None # type: ignore
8080
country: String(3) # type: ignore
8181
coordinates: GeoLocation
82+
evse_uid: CiString(36) # type: ignore
8283
evse_id: CiString(48) # type: ignore
8384
connector_id: CiString(36) # type: ignore
8485
connector_standard: ConnectorType

ocpi/modules/cdrs/v_2_3_0/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CdrLocation(BaseModel):
7979
state: String(20) | None # type: ignore
8080
country: String(3) # type: ignore
8181
coordinates: GeoLocation
82+
evse_uid: CiString(36) # type: ignore
8283
evse_id: CiString(48) # type: ignore
8384
connector_id: CiString(36) # type: ignore
8485
connector_standard: ConnectorType

0 commit comments

Comments
 (0)