forked from snarfed/mockfacebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
31 lines (25 loc) · 803 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import webapp2
import json
class TestUsersHandler(webapp2.RequestHandler):
ROUTES = [
(r'/(\d+)/accounts/test-users', 'app.TestUsersHandler'),
]
@classmethod
def init(cls, conn, me):
"""
conn: sqlite3.Connection
"""
cls.conn = conn
def get(self, app_id):
sql = """
SELECT DISTINCT user_id, token
FROM oauth_access_tokens;
"""
cursor = self.conn.execute(sql)
rows = cursor.fetchall()
results = {'data': []}
for row in rows:
user_id, token = row
results['data'].append({'id': user_id, 'access_token': token})
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
json.dump(results, self.response.out, indent=2)