Skip to content

Commit

Permalink
Add error handling for failed login
Browse files Browse the repository at this point in the history
  • Loading branch information
markphip committed Jun 21, 2024
1 parent 32bd733 commit 91875b6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/external-repository/scripts/external-git
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ case "${SUBCOMMAND}" in
# Get token using OIDC
if [ "$2" = "get" ]; then
FIC=$(curl -s -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://AzureADTokenExchange" | jq -r '.value')
az login --service-principal -u ${EXT_GIT_AZURE_CLIENT_ID} --tenant ${EXT_GIT_AZURE_TENANT_ID} --federated-token "${FIC}" --allow-no-subscriptions > /dev/null 2>&1
ADO_TOKEN=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 | jq -r .accessToken)
if az login --service-principal -u ${EXT_GIT_AZURE_CLIENT_ID} --tenant ${EXT_GIT_AZURE_TENANT_ID} --federated-token "${FIC}" --allow-no-subscriptions --only-show-errors &>/dev/null; then
ADO_TOKEN=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 | jq -r .accessToken)
else
ADO_TOKEN="ERROR"
fi
echo "username=${EXT_GIT_USERNAME}"
echo "password=${ADO_TOKEN}"
else
Expand Down Expand Up @@ -53,4 +56,4 @@ case "${SUBCOMMAND}" in
exit 0
;;
esac
exit $?
exit $?

0 comments on commit 91875b6

Please sign in to comment.