Forked from davidthewatson/python-requests-postgrest-client.py
Last active
November 13, 2017 20:02
-
-
Save zhiboz/ba335a461409ae2a3c6b0141649b5c70 to your computer and use it in GitHub Desktop.
python-requests-postgrest-client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import requests_jwt | |
import json | |
# email and password auth through postgrest | |
resp = requests.post('http://localhost:3000/rpc/login', json={"email": "you@yours.com", "pass": "dog"}) | |
print resp # <Response [200]> | |
# JWT token-based auth through postgrest using the returned token from above | |
auth = requests_jwt.JWTAuth(json.loads(resp.text)['token']) | |
r = requests.get('http://localhost:3000/weight', auth=auth) | |
for each in r.json(): | |
print(each) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment