Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Daml Hub Service Account LoginForum ↗

Daml Hub Service Account Login

App Development10 posts299 views3 likesLast activity Jun 2022
AR
aryaOP
May 2022

The docs here https://hub.daml.com/docs/api#operation/saLogin don’t show a request sample, how should the body of the POST request look for this request?

SA
Sammy_Abed
May 2022 1

Hi,

The requests should look like this:
curl -XPOST https://${ledgerId}.daml.app/.hub/v1/sa/login -u ${service-account-credential}
(where -u indicates Basic Auth, i.e. a Authorization: Basic ${base64 encoded credential} header)

SA
Sammy_Abed
May 2022 1

the service account credential is of the form username:password, and can be copied from Hub in the ledger’s service accounts page

AR
arya
May 2022

hey thanks @Sammy_Abed ! So for a user in Python, we’d have to add this Authorization: Basic ${base64 encoded credential} as a header? Do you happen to have an example in Python?

Also, I only ever got the service account username, never a password, how do I get that? or is the credentials supplied on creation the password? If that’s the case, what is the username?

SA
Sammy_Abed
Jun 2022 1

To get both the username and password, try using the Copy To Clipboard icon as only the username is visible in the text field.

AR
arya
Jun 2022

For a Service Account there is no “Copy to Clipboard” icon?

AL
Alex_Matson
Jun 2022

Hi @arya,

To clarify:

  1. Upon creating a new Service Account for the first time, you are presented with a secret credential that is displayed once.
  2. At this time, you’ll see the credential ID and a “Copy to Clipboard” button which includes the entire credential, which is one string value formatted as cred-id:secret
  3. When making a request to the SA login endpoint, you’ll want to submit the header of the form Authorization: Basic ${base64(cred-id:secret)}
  4. Alternatively to (3), if your HTTP client has a helper method for Basic auth you may use cred-id and secret as username and password respectively. For example, with Python and requests:
response = requests.post('https://myapp.daml.app/.hub/v1/sa/login', auth=('cred-id', 'secret'))

Hope that helps!

AR
arya
Jun 2022

thanks @Alex_Matson ! That is very helpful. Two things:

  1. when I copied the credential generated in step 2, it was in the form cred-<HASH> and not in the form <cred-id>:<secret>.
  2. what is cred-id here? is it the label given to the service account during its creation?
AL
Alex_Matson
Jun 2022

Here’s a concrete example:

# complete credential (copied via the clipboard button)
cred-1822bb09-387e-443f-a0b2-6ac75bc3c167:OnB3i9CAOvKW42sy

# credential id
cred-1822bb09-387e-443f-a0b2-6ac75bc3c167

# secret
OnB3i9CAOvKW42sy

(The label you give it doesn’t factor in to any of this)

AR
arya
Jun 2022

Oh thank you! the cred-id was so long that the secret blended in and I missed it my bad, thanks for the example!

← Back to Discussions