#!/bin/sh

# user accounts
auth_user="username"
auth_pass="password"

curl --location --request POST 'https://signin.tradestation.com/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: did=s%3Av0%3A105049e0-bbfd-11ec-bb51-ed5de56b2252.dqvS3Nsv49Ov2hf3fXLxyKvTY0olYFM0l3X5Clr5CbI; did_compat=s%3Av0%3A105049e0-bbfd-11ec-bb51-ed5de56b2252.dqvS3Nsv49Ov2hf3fXLxyKvTY0olYFM0l3X5Clr5CbI' \
--data-urlencode 'grant_type=http://auth0.com/oauth/grant-type/password-realm' \
--data-urlencode 'client_id=Sg8Fa1mdIC7IAEYxbHw6wZn4gzjLccl7' \
--data-urlencode 'client_secret=DPVVY_m0fnwNQT3dxj-IMMG8O5MaU25ZLQgeZmhuBteywovhML7UERHcS-3zPI2G' \
--data-urlencode 'audience=https://api.tradestation.com' \
--data-urlencode 'realm=auth0-api-connection' \
--data-urlencode 'scope=openid profile ReadAccount Trade TradeStation MarketData News Matrix OptionSpreads offline_access HotLists' \
--data-urlencode "username=$auth_user" \
--data-urlencode "password=$auth_pass" 2>&1 | grep -o '"access_token":"[^"]*' | grep -o '[^"]*$'