<commit_before>: ${baseURL:="https://api.respoke.io"}

: ${appSecret:?"appSecret required"}
: ${appId:?"appId required"}
: ${endpointId:?"endpointId required"}
: ${roleId:?"roleId required"}

body='{
    "appId": "'$appId'",
    "endpointId": "'$endpointId'",
    "ttl": 3600,
    "roleId": "'$roleId'"
}'

tokenRequest=$(curl -s -X POST \
    -H 'App-Secret: '$appSecret -H 'Content-type: application/json' \
    -d "$body" $baseURL/v1/tokens)

# Extract the tokenId from the returned JSON
tokenId=$(expr "$tokenRequest" : '.*"tokenId": *"\(.*\)"')

body='{ "tokenId": "'$tokenId'" }'

curl -X POST -H 'Content-type: application/json' \
    -d "$body" $baseURL/v1/session-tokens
<commit_msg>Another typo in the curl command for sh examples<commit_after>: ${baseURL:="https://api.respoke.io"}

: ${appSecret:?"appSecret required"}
: ${appId:?"appId required"}
: ${endpointId:?"endpointId required"}
: ${roleId:?"roleId required"}

body='{
    "appId": "'$appId'",
    "endpointId": "'$endpointId'",
    "ttl": 3600,
    "roleId": "'$roleId'"
}'

tokenRequest=$(curl -s -X POST \
    -H "App-Secret: $appSecret" -H 'Content-type: application/json' \
    -d "$body" $baseURL/v1/tokens)

# Extract the tokenId from the returned JSON
tokenId=$(expr "$tokenRequest" : '.*"tokenId": *"\(.*\)"')

body='{ "tokenId": "'$tokenId'" }'

curl -X POST -H 'Content-type: application/json' \
    -d "$body" $baseURL/v1/session-tokens

{'fraction_non_alphanumeric': 0.23114869626497533, 'fraction_numerical': 0.008456659619450317, 'mean_word_length': 4.318352059925093, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2252422', 'n_tokens_mistral': 538, 'n_tokens_neox': 520, 'n_words': 116}