Skip to content

Commit eeaa286

Browse files
committed
feat: make auth possible also via URL args and json body
This is needed as IFTTT doesn't support Headers for passing additional information. The URL args does expose your sensitive information in the Heroku router logs though.
1 parent 7054dfc commit eeaa286

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@ def token_required(f):
2828
def decorated_function(*args, **kwargs):
2929
if 'notion_token' in request.headers:
3030
return f(request.headers['Notion-Token'], *args, **kwargs)
31+
elif 'notion_token' in request.args:
32+
return f(request.args['notion_token'], *args, **kwargs)
33+
elif request.json is not None and 'notion_token' in request.json:
34+
# Popping the notion_token field as it would effect some of the
35+
# block updating as we use whole response for properties.
36+
notion_token = request.json.pop('notion_token')
37+
return f(notion_token, *args, **kwargs)
3138
else:
32-
return 'Request is missing `Notion-Token` header (token_v2 from notion.so)', 401
39+
return 'Request is missing `Notion-Token` header or `notion_token` in request body or `notion_token` in URL args.', 401
3340
return decorated_function
3441

3542

0 commit comments

Comments
 (0)