This repository was archived by the owner on Jun 17, 2024. It is now read-only.
Commit 8971c76 1 parent 0ddcb64 commit 8971c76 Copy full SHA for 8971c76
File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -51,15 +51,16 @@ def auth_redirect_uri():
51
51
return redirect (request .url_root ) # go back home after successful auth
52
52
53
53
54
- # Using auth token boosts request limit to 400
55
- @app .before_request
56
- def check_session ():
57
- if '/auth_redirect_uri/' != request .path :
58
- if 'user_id' not in session or 'access_token' not in session :
59
- auth_code_url = authwrapper .get_auth_code_url (request .url_root )
60
- return redirect (auth_code_url )
61
-
62
- return None
54
+ # i've hardcoded my token for all automated requests. comment this out while developing on localhost.
55
+ # TODO: break this out for visitors to the site and automated requests
56
+ # @app.before_request
57
+ # def check_session():
58
+ # if '/auth_redirect_uri/' != request.path:
59
+ # if 'user_id' not in session or 'access_token' not in session:
60
+ # auth_code_url = authwrapper.get_auth_code_url(request.url_root)
61
+ # return redirect(auth_code_url)
62
+ #
63
+ # return None
63
64
64
65
65
66
@app .errorhandler (404 )
Original file line number Diff line number Diff line change 2
2
from datetime import datetime
3
3
import html
4
4
import logging
5
+ import os
5
6
import re
6
7
import time
7
8
@@ -17,6 +18,8 @@ class StockTwitsWrapper:
17
18
18
19
mysql_conn = MysqlWrapper .get_connection ()
19
20
21
+ oauth_token = os .environ .get ('ST_OAUTH_TOKEN' )
22
+
20
23
bot_blacklist = [727510 ]
21
24
22
25
@classmethod
@@ -55,9 +58,13 @@ def get_ticker(self, ticker):
55
58
get_ticker_url = 'https://api.stocktwits.com/api/2/streams/symbol/'
56
59
url_postfix = '.json?'
57
60
pagination_since = self .__get_last_message (ticker )
61
+ # TODO: use visitors token for watchlist, etc.
58
62
# only time we don't have access_token is on localhost so kind of an unnecessary check
59
- if 'access_token' in session :
60
- url_postfix = '%s&access_token=%s' % (url_postfix , session ['access_token' ])
63
+ # if 'access_token' in session:
64
+ # url_postfix = '%s&access_token=%s' % (url_postfix, session['access_token'])
65
+
66
+ # use my token for all automated calls
67
+ url_postfix = '%s&access_token=%s' % (url_postfix , self .oauth_token )
61
68
62
69
# TODO: only messages 'since' show up.
63
70
# TODO: store last 30 messages in DB or always fetch last 30 and do fake pagination here?
You can’t perform that action at this time.
0 commit comments