Hi,
I've been beating my head against a wall for about 2 hours trying to figure out why this won't work. Whenever I POST to my script I hit the passphrase protection error I have set up even though the passphrase I'm POSTing and the passphrase I have stored are the same (I don't think double quotes (") vs single quotes (') should matter, but maybe I'm mistaken about that). The most annoying part is when I call the script in bash with a print statement for one of the my secret variables, it shows up just fine.
from main.py:
from flask import Flask, request, render_template
import config, json, requests
import datetime as dt
from pytz import timezone
import alpaca_trade_api as tradeapi
import sys
import time
app = Flask(__name__)
QUOTE_API_KEY = config.QUOTE_API_KEY
QUOTE_API_SECRET = config.QUOTE_API_SECRET
WEBHOOK_PASSPHRASE = config.WEBHOOK_PASSPHRASE
@app.route('/webhook', methods=['POST'])
def webhook():
try:
webhook_message = json.loads(request.data)
if webhook_message['passphrase'] != WEBHOOK_PASSPHRASE:
return {
'code': 'error',
'message': 'nice try buddy'
}
from config.py, located at /home/inkheist/tqqq-swing/config.py:
import os
from dotenv import load_dotenv
load_dotenv()
DISCORD_WEBHOOK_URL_LIVE = os.getenv("DISCORD_WEBHOOK_URL_LIVE")
DISCORD_WEBHOOK_URL_TEST = os.getenv("DISCORD_WEBHOOK_URL_TEST")
QUOTE_API_KEY = os.getenv("QUOTE_API_KEY")
QUOTE_API_SECRET = os.getenv("QUOTE_API_SECRET")
WEBHOOK_PASSPHRASE = os.getenv("WEBHOOK_PASSPHRASE")
from my .env file, located at /home/inkheist/tqqq-swing/.env:
DISCORD_WEBHOOK_URL_LIVE="######"
DISCORD_WEBHOOK_URL_TEST="######"
QUOTE_API_KEY='#####'
QUOTE_API_SECRET='######'
WEBHOOK_PASSPHRASE="####"
from WSGI.py:
import sys
path = '/home/inkheist/tqqq-swing'
if path not in sys.path:
sys.path.append(path)
from main import app as application
import os
from dotenv import load_dotenv
project_folder = os.path.expanduser('~/') # adjust as appropriate
load_dotenv(os.path.join(project_folder, '.env'))
If I put the passphrase directly into my script it works just fine, but for some reason it won't read in from my .env file. Any help is appreciated!
edit: updated code as it currently is