
이미 쉘 스크립트를 작성했지만 작동하지 않습니다. 먼저 토큰을 반환해야 하고 로그인한 다음 API를 등록해야 하는데 빈 응답이 표시됩니다.
이것이 내 쉘 스크립트가 수행해야 하는 작업입니다.
#!/bin/bash
# Begin
TEMP=$(getopt -n "$0" -a -l "base_url:,auth0_url:,register_url:,username:,password:,openapi_spec:,base_path:,label:,test_email:" -- -- "$@")
[ $? -eq 0 ] || exit
eval set -- "$TEMP"
while [ $# -gt 0 ]; do
case "$1" in
--base_url) BASE_URL="$2"; shift ;;
--auth0_url) AUTH0_URL="$2"; shift ;;
--register_url) REGISTER_URL="$2"; shift ;;
--username) TEST_USER="$2"; shift ;;
--password) TEST_PWD="$2"; shift ;;
--openapi_spec) OPENAPI_SPEC="$2"; shift ;;
--base_path) BASEPATH_SPEC="$2"; shift ;;
--label) LABEL="$2"; shift ;;
--test_email) TEST_EMAIL="$2"; shift ;;
--) shift ;;
esac
shift
done
# Set defaults for configurable options
BASE_URL=${BASE_URL:-"https://dev.cloudnetwork.in"}
AUTH0_URL=${AUTH0_URL:-"https://dev-yxxxxxxx1.us.auth0.com"}
REGISTER_URL=${REGISTER_URL:-"https://dev.cloudnetwork.in/apis/register"}
#f [ "$BASE_URL" = "" ];
#then
# BASE_URL="https://dev.cloudnetwork.in"
#fi
### IM STRUCK AT THIS CURL COMMAND ###
echo " "
token=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${TEST_USER}'", "password": "'${TEST_PWD}'"}' ${AUTH0_URL}/login ${BASE_URL}/login ${REGISTER_URL}/login | jq -r .token)
echo "generated token is:" $token
echo " "
data=$(curl -k -s -H "Accept: application/json" -H "Content-Type: application/json" --location --request POST "https://dev.cloudnetwork.in/api/v1/api/test" --header "Authorization: Bearer $token" -d '{"base_url":"'"${BASE_URL}"'","auth0_url":"'"${AUTH0_URL}"'","register_url":"'"${REGISTER_URL}"'","openapi_spec":"'"${OPENAPI_SPEC}"'","base_path":"'"${BASEPATH_SPEC}"'","label":"'"${LABEL}"'","test_email":"'"${TEST_EMAIL}"'"}' | jq -r .token)
label_name=$(jq -r '.label')
created_email=$(jq -r '.created_by_email')
echo "Successfully created the API Register."
echo "LabelName: $label_name"
echo "CreatedEmail: $created_email"
echo 'Script Execution is Done.'
echo "Successfully created $NoProjectsToCreate projects in $TEST_HOSTNAME env
여기 내 출력 명령이 있습니다
./dev-registry.sh --base_url "https://dev.cloudnetwork.in" --auth0_url "https://dev-yxxxxxxxx1.us.auth0.com" --register_url "https://dev.cloudnetwork.in/apis/register" --username "[email protected]" --password "123456" --openapi_spec "https://xxxxxx.yaml" --base_path "https://xxxxxxx/v2" --label "Demo" --test_email "[email protected]"
다음은 내 웹사이트 로그인 브라우저 응답입니다. 아래에는 여기에서 가져온 모든 세부 정보가 표시되어 있으며 컬 내부의 쉘 스크립트에 추가됩니다.
{
BASE_URL: 'https://dev.cloudnetwork.in',
AUTH0_URL: 'https://dev-yxxxxxxxxx1.us.auth0.com',
USERNAME: '[email protected]',
PASSWORD: '123456',
REGISTER_URL:'https://dev.cloudnetwork.in/apis/register',
},
1. GENERAL
Request URL: https://dev.cloudnetwork.in/api/v1/api/test
Request Method: POST
2. Request Header
authority: api.dev.cloudnetwork.in
method: POST
path: /api/v1/api/test
Authorization: Bearer
eyJhxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxeaLvIBUOsH6gGQ1xxxxxxxxxxxxxxxx0huyw
3. Payload
openapi_spec: "https://xxxxx/xxxxx.yaml"
base_path: "https://xxxxxxx/v2"
test_email: "[email protected]"
label: "demo"
{"openapi_spec":"https://xxxxxxxx.yaml","base_path":"https://xxxxxxxx/v2","label":"demossss"}
그래서 위의 내용을 이용하여 토큰을 가져오고, 로그인하고, API를 등록합니다. 위의 쉘 스크립트에서 동일한 작업을 수행하고 싶지만 빈 응답이 반환됩니다.
내가 어디서 잘못되었는지 모르겠습니다.