Skip to content

Instantly share code, notes, and snippets.

@kimdre
Last active August 11, 2022 21:10
Show Gist options
  • Save kimdre/6e31383feba8e1b1c3c0785be6567d13 to your computer and use it in GitHub Desktop.
Save kimdre/6e31383feba8e1b1c3c0785be6567d13 to your computer and use it in GitHub Desktop.
Automated login to openshift
# Add this to your .bashrc or .zshrc etc.
function oc {
if [[ "$@" == "login" ]]
then
OS_USER="my_user"
OS_PASSWORD="my_password"
OS_URL="https://openshift.master.com:443"
echo Optaining api token...
export OC_TOKEN=$(curl -u ${OS_USER}:${OS_PASSWORD} -kv -H "X-CSRF-Token: xxx" "${OS_URL}/oauth/authorize?client_id=openshift-challenging-client&response_type=token" 2>&1 | ggrep -oP "access_token=\K[^&]*")
command oc login --token=${OC_TOKEN}
else
command oc "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment