Skip to content

Instantly share code, notes, and snippets.

@davidthewatson
Created December 22, 2015 05:33
Show Gist options
  • Save davidthewatson/7578f0f9c84aa129cd66 to your computer and use it in GitHub Desktop.
Save davidthewatson/7578f0f9c84aa129cd66 to your computer and use it in GitHub Desktop.
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