Daml hub - access error

I have developed a .Net core-based service in order to feed data from external sources to DAML smart contract which is deployed on DAML Hub. I am getting the token from below:

However, I am uploading my code snippet as well. and also attaching the error msg.



WhatsApp Image 2022-03-23 at 10.23.19 AM

Json web tokens (JWTs) are bearer tokens; you should use a value of "Bearer" for the authorization scheme instead.

string myToken = ...;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", myToken)

how to get a bearer value.

The token you already have is the bearer value; in your code snippet, simply replace "oracleParty" with "Bearer".

I did it. But each time my token expired and now getting this bad request error msg.


Separately in your code example, I notice you’re exercising a choice by contract ID on what looks like a consuming choice. A better approach might be to use contract keys if you’d rather use stable identifiers to refer to contract instances; otherwise you will need to repeatedly update your code every time you exercise that choice, since the contract ID will have changed.

Note that the party tokens that you fetch through the UI are meant to be a convenience to help you try examples and such, but they do expire for security purposes. If you want a longer-lived token, service accounts are a better option meant for establishing applications that are expected to be long-lived. You can find these on the Identities tab as well (where you copied those JWTs originally).