-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test initial stubs against gotrue-example site
- Loading branch information
Joel Lee
authored and
Joel Lee
committed
Jan 25, 2021
1 parent
0e4fbd0
commit 583da03
Showing
3 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
import requests | ||
import user | ||
import re | ||
import urllib | ||
import json | ||
HTTPRegexp = /^http:\/\//; | ||
defaultApiURL = "/.netlify/identity" | ||
|
||
class Client: | ||
def __init__(url, audience='', setCookie=False): | ||
pass | ||
|
||
def _request(): | ||
pass | ||
if re.match(HTTPRegexp): | ||
# TODO: Decide whether to convert this to a logging statement | ||
print("Warning:\n\nDO NOT USE HTTP IN PRODUCTION FOR GOTRUE EVER!\nGoTrue REQUIRES HTTPS to work securely.") | ||
if audience: | ||
self.audience = audience | ||
self.setCookie = setCookie | ||
self.BASE_URL = "https://distracted-elion-6bf6a2.netlify.app/.netlify/identity/" | ||
def _request(path, options=[]): | ||
options = option.headers or [] | ||
aud = options.audience or self.audience | ||
if aud: | ||
options.headers['X-JWT-AUD'] = aud | ||
|
||
|
||
def settings(): | ||
pass | ||
|
||
def signup(email, password, data): | ||
pass | ||
data = json.dumps({ | ||
"email": "[email protected]", | ||
"password": "yadayada" | ||
}) | ||
requests.post("https://distracted-elion-6bf6a2.netlify.app/.netlify/identity/signup", data) | ||
|
||
def login(): | ||
pass | ||
|
@@ -39,8 +60,18 @@ def currentUser(): | |
pass | ||
|
||
def verify(type, token, remember): | ||
requests.post("https://distracted-elion-6bf6a2.netlify.app/.netlify/identity/verify",data=json.dumps({"type": "signup", "token": "cixoe6C7k1tqx2UuYL_O3w"})) | ||
pass | ||
|
||
def _setRememberHeaders(remember): | ||
pass | ||
if self.setCookie: | ||
self.api.defaultHeaders = self.api.defaultHeaders or {}; | ||
self.api.defaultHeaders['X-Use-Cookie'] = remember ? '1' : 'session'; | ||
|
||
def grant_token(type, payload): | ||
payload = json.dumps({ | ||
"email": "[email protected]", | ||
"password": "yadayada" | ||
}) | ||
headers = { 'Content-Type': 'application/x-www-form-urlencoded' } | ||
requests.post("https://distracted-elion-6bf6a2.netlify.app/.netlify/identity/verify",data=json.dumps({"type": "signup", "token": "tokenthing"})) |
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