Quick Tip: LCM API swagger authentication

Quick tip how to generate the basic auth token which can be used with the API Swagger

  • LCM API Swagger: https://LCM-FQDN/api/

Swagger:

Swagger authorize:

Script:

1vi lcm_basic_auth.sh
1#!/bin/bash
2
3TOKEN=`echo -n $1:$2 | base64`
4
5echo "Basic $TOKEN"
1chmod +x basic_auth.sh

Usage:

1./basic_auth.sh 'admin@local' 'VMware123!'

Example Ouput:

1root@scriptserver:~# ./basic_auth.sh 'admin@local' 'VMware123!'
2Basic YWRtaW5AbG9jYWw6Vk13YXJlMTIzIQ==

Now open Swagger and click on the Authorize button. In the dialog copy and paste the output of the script:

1Basic YWRtaW5AbG9jYWw6Vk13YXJlMTIzIQ==

and click on Authorize

Now you are authorized and you can run API commands in Swagger.