(20241230) Paper Trading auth added.
This commit is contained in:
@@ -163,8 +163,41 @@ async def request_oauth_authorization_url(
|
||||
)
|
||||
|
||||
# Start by assuming failure:
|
||||
success = False
|
||||
auth_url = None
|
||||
|
||||
# ┏┓ ┏┓ ┏┳┓ ┓•
|
||||
# ┣ ┏┓┏┓ ┃┃┏┓┏┓┏┓┏┓ ┃ ┏┓┏┓┏┫┓┏┓┏┓
|
||||
# ┻ ┗┛┛ ┣┛┗┻┣┛┗ ┛ ┻ ┛ ┗┻┗┻┗┛┗┗┫
|
||||
# ┛ ┛
|
||||
|
||||
if inbound_data.client == "paperTrading":
|
||||
|
||||
# Immediately save the details against that token id:
|
||||
success = await current_app.paper_trading_controller.set_token_direct(
|
||||
sql_conn = current_app.sql_writer,
|
||||
mongo_data_conn = current_app.data_mongo,
|
||||
auth_token = CoreAuthTokenModel(
|
||||
serviceType = "stockTrading",
|
||||
client = inbound_data.client,
|
||||
authType = "auth",
|
||||
user = kwargs["session_info"],
|
||||
clientUserId = {
|
||||
"username": inbound_data.auth.username
|
||||
},
|
||||
auth = inbound_data.auth.model_dump(),
|
||||
status = "active",
|
||||
syncFreq = 1500
|
||||
),
|
||||
token_notes = {
|
||||
"username": inbound_data.auth.username
|
||||
},
|
||||
session_token = inbound_headers["X-Session-Token"]
|
||||
)
|
||||
|
||||
# Check if things were successful:
|
||||
if not success: auth_url = None
|
||||
|
||||
# ┏┓ ┏┓ ┓┓ ┓┏┓•
|
||||
# ┣ ┏┓┏┓ ┏┛┏┓┏┓┏┓┏┫┣┓┏┓ ┃┫ ┓╋┏┓
|
||||
# ┻ ┗┛┛ ┗┛┗ ┛ ┗┛┗┻┛┗┗┻ ┛┗┛┗┗┗
|
||||
@@ -214,8 +247,8 @@ async def request_oauth_authorization_url(
|
||||
|
||||
# Done here:
|
||||
return ResponseModel(
|
||||
status_code = StatusCodes.OK if auth_url else StatusCodes.FAILED,
|
||||
http_code = HttpCodes.SUCCESS if auth_url else HttpCodes.INTERNAL_SERVER_ERROR,
|
||||
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
|
||||
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
|
||||
data = {
|
||||
"client": inbound_data.client,
|
||||
"authorizationUrl": auth_url
|
||||
|
||||
Reference in New Issue
Block a user