Skip to content

AuthCli

AuthCli is used by UnityCatalogCli to handle auth sub-commands.

$ ./bin/uc auth --help
Please provide a valid sub-command for auth.
Valid sub-commands for auth are: login
For detailed help on auth sub-commands, use bin/uc auth <sub-command> --help

Exchange and Login

login and exchange use doExchange for authentication with the following difference:

Handle Command Line

void handle(
  CommandLine cmd,
  ApiClient apiClient)

handle handles the given cmd.

Subcommand Handler
login One of the following based on identity_token param:

handle is used when:

Exchange

String exchange(
  ApiClient apiClient,
  JSONObject json)

exchange de-serializes the given json object into a collection (that is supposed to include identityToken key based on identity_token CLI parameter).

exchange doExchange with the identityToken identity token.

Login

String login(
  ApiClient apiClient,
  JSONObject json)

login...FIXME

doExchange

String doExchange(
  ApiClient apiClient,
  Map<String, String> login)

doExchange requests the given ApiClient for the base URI to access /auth/tokens API endpoint with the following query parameters:

Query Parameter Value
grant_type urn:ietf:params:oauth:grant-type:token-exchange
requested_token_type urn:ietf:params:oauth:token-type:access_token
subject_token_type urn:ietf:params:oauth:token-type:id_token
subject_token The value of identityToken in the given login collection

doExchange sends a POST request to /auth/tokens API endpoint with application/x-www-form-urlencoded content type.

In the end, doExchange creates a LoginInfo with access_token (from the response).