Skip to content

Credential Process Scripts

Ben Watson edited this page Sep 20, 2021 · 1 revision

If you have a custom use case where you need to need to authenticate against the ALKS CLI that isn't supported out of the box, you can write a custom script that sends credentials to the ALKS CLI by following the instructions below:

  1. Create a script file
  2. In the script file, write your logic that fetches either your network password, ALKS refresh token, or both
    1. If you want, you can add debug statements by printing to stderr (file descriptor 2). Anything you print to stdout will be treated as part of the output of your script which could break the process, so be sure to only print debug statements to stderr
  3. Add logic to your script file so that it prints out your credentials in the following JSON format: {"password":"your password", "refresh_token": "your refresh token"}
    1. If you only want to fetch your password, you can omit the "refresh_token" field, or if you only want to fetch your refresh token, you can omit the "password" field. If you provide both, the ALKS CLI will use the most preferred method, which at this time is "refresh_token"
  4. Make sure your script is executable by running chmod +x yourScript.sh
  5. Run alks developer configure and when asked how to authenticate, select the option for credential-process. This will prompt you for the name of the script you just wrote. Enter the name of the script and you're all set.
    1. ALKS will remember what script to run by writing it to the file named ~/.alks-cli/credentials as the value of the credential_process key

Example

Write a script file named myScript.sh like this:

#!/bin/bash

echo "This is a debug statement" >&2

myPassword="thisIsMyPassword"
myToken="thisIsMyToken"

echo "{\"password\": \"$myPassword\", \"refresh_token\": \"$myToken\"}"

and then run chmod +x myScript.sh. Now run alks developer configure and when asked how to authenticate, select the option for credential-process and enter /path/to/your/script/myScript.sh (but replace the path with the absolute path to your script). The ALKS CLI will then test the script by running it and use thisIsMyToken as the refresh token to authenticate from now on.

Clone this wiki locally