We will use an example configuration for and Event Hub service. The corresponding data for your service can be found on the details page of the share access policy you want to use. More information on this topic can be found here
From the shared access policy "hub-nifi"'s detail page we can get all the information we need to create our token from the connection string-primary key field
A SAS token is simply the hash of a string consisting of two substrings, the endpoint URL and the date the token should expire. The expiration date should be in Unix epoch format. The format for the string is <resourceURI> + \n + <expiry>
To make a HTTP request to an Event Hubs endpoint a "Authorization" property must be added to the headers of the request. IMPORTANT URL encode the hash before using it in the token
The value of the authorization property is formatted as
what is even more confusing, it that the URL you encode and hash is http; this however does not work, the hashed URL should be https
the text says (or at least suggest) that the string contain of the URL with the "\n" and date append, must be URL-encoded, but this wont work: first the URL must be encoded and after that, the "\n" and date must be appended.