シングルサインオンのウェブサイトまたはページで curl を使用する方法

シングルサインオンのウェブサイトまたはページで curl を使用する方法

すでにシェル スクリプトを作成しましたが、動作しません。最初にトークンを返し、ログインしてから 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]"

これは私のウェブサイトのログインブラウザの応答です。以下はここから取得してcurl内のシェルスクリプトに追加したすべての詳細を示しています。

 {
    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 を登録しています。上記のシェル スクリプトから同じことを実行したいのですが、空の応答が返されます。

どこが間違っているのか分かりません。

関連情報