Below is the bash-script that i use to parse the json-response from my OAuth provider. My intention is to extract only the access-token from the json response
CLIENT_ID=MASKED
CLIENT_SECRET=MASKED
RESOURCE=MASKED
TOKEN_JSON_RESPONSE=$(
    curl https://corp.company.com/adfs/oauth2/token/ -H 'Accept: application/json' -H 'Content-Type: application/x-www-form-urlencoded' -d 'client_id='$CLIENT_ID'&client_secret='$CLIENT_SECRET'&grant_type=client_credentials&resource='$RESOURCE
)
echo 'The token response is ' $TOKEN_JSON_RESPONSE
echo ' @@@@@@@@@@@@@@@@@  '
ACCESS_TOKEN=$TOKEN_JSON_RESPONSE | jq '.access_token'
echo 'The access token is '$ACCESS_TOKEN
I am getting the JSON response properly and below is that
{
   "access_token":"eyJxxxxxxxx",
   "token_type":"bearer",
   "expires_in":3600
}
All that i need is to just to extract the value in the access_token .. Currently in the above script, i get an empty string after using jq-parser
Update:
when i directly print this way, it works echo $TOKEN_JSON_RESPONSE|jq '.access_token’
whereas when i put the same in a variable it doesn't work
ACCESS_TOKEN=$TOKEN_JSON_RESPONSE|jq '.access_token’
echo $ACCESS_TOKEN
 
    