[API] Login over ssh


I want to retrieve data from an app outside calponia. I
tried first to get an access token from this endpoint with this basic script



EMAIL=$(cat "$SSH_PUB_KEY" | awk '{print $3}')
KEY=$(cat "$SSH_PUB_KEY")

# Login
# https://api.calponia.com/v2/explorer/#operation/post_users_login_ssh
DATA="{ \"email\": \"${EMAIL}\", \"key\": \"${KEY}\"}"

curl -s --request POST \
-H "Content-Type: application/json" \
--data "$DATA" \
--url https://api.calponia.com/v2/users/login/ssh | jq

I get a 401

  "error": {
    "status": 401,
    "code": "NOT_AUTHORIZED",
    "title": "No valid authorization provided",
    "detail": "The request requires authorization, but a valid one was not provided."

I may be wrong with what endpoint. Can we initialize a token from it without already be authentified?

Hey @emmanuel.roux,

looks like that endpoint is restricted to a specifc role, but there is an easier way for you, when you want to authenticate via ssh:
ssh -p 22 ctl@git.calponia.com api login --email your@email.address --accesstoken.

This will provide you a personal user-token. Depending on your use-case you may want to switch to an device-token, if you are developing for a connectivity-device. Those tokens can be created using the calponia-plaform UI.

You can find more information about the ctl here.

Hello @thomas.schuerle,

thank you for your answer. I tried to login via ssh but unfortunately, it seems like I met resolving problems:

> ssh -p 22 ctl@git.calponia.com api --help
ssh: Could not resolve hostname git.calponia.com: Name or service not known

When trying with calponia.bosch.com, I get an answer from the server, however a token generation did not work for me at this address.

> ssh -p 2359 ctl@calponia.bosch.com api --help
Interact with the calponia api. You have the ability to quickly login or logout.

  ctl@local.calponia.dev api
  ctl@local.calponia.dev api [command]

  # Login into calponia
  ctl@local.calponia.dev api login
  # Logout from calponia
  ctl@local.calponia.dev api logout

Available Commands:
  login       Creates an accesstoken for the user
  logout      Invalidates given accesstoken

  -h, --help   help for api

Use "ctl@local.calponia.dev api [command] --help" for more information about a command.

I’ll pm you to know more about this topic.

The first one looks like you in cooperate network, where you need to specify a proxy. You might end up in the next error, cause that network will block ssh-traffic at all by default. A suitable network for development is recommended.

For the second one, please verify:

  • You specify the same email like on calponia. Click on the settings icon on calponia.bosch.com. In the tab “Account” the email is displayed
  • Make sure you have added the correct public key. You can find your keys on the same page in the tab “Keys”