Skip to content
Discussions/App Development/'ledgerId missing in access token' says /v1/createForum ↗

'ledgerId missing in access token' says /v1/create

App Development4 posts181 views1 likesLast activity Mar 2024
AR
Artur_PoorOP
Feb 2024

Hi,

I have an access token with payload

{
  "sub": "alice",
  "aud": "https://daml.app.template.example.com",
  "exp": 1707556819
}

When I send a POST request to /v1/create with the access token, JSON api returns

{"errors":["ledgerId missing in access token"],"status":401}

I find that confusing because user tokens aren’t required to have ledgerId. What do I misunderstand here?

BE
bernhard
Feb 2024

Just a guess, but since you didn’t specify a “scope”, you are using an audience based token. But your “aud” field looks like it has an invalid format. Likely the someParticipantId is parsed to ledgerId somewhere and causing the misleading error message.

AR
Artur_Poor
Feb 2024

Could be. For the record, I added all fields that json api reported missing, and removed all fields that I could without json api complaining (so the smallest set of fields that json api happily accepted), and here is what I got:

{
  "sub": "alice",
  "aud": "https://daml.app.template.example.com",
  "ledgerId": "userParticipant",
  "applicationId": "alice",
  "actAs": ["alice::1220ea091546054ae5bf4b927d1a67fddf86592ad71e323fdd6ee1c5b96295582b91"]
}

This doesn’t conform to any of the token formats (scope-based, audience-based or custom) in the documentation, which is odd.

AR
Artur_Poor
Mar 2024

This payload is also valid according to json api:

{
  "scope": "daml_ledger_api",
  "iat": 1711104773,
  "aud": "https://daml.app.template.example.com",
  "sub": "alice"
}
← Back to Discussions