-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_silent.py
More file actions
44 lines (32 loc) · 1.59 KB
/
git_silent.py
File metadata and controls
44 lines (32 loc) · 1.59 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
import httplib2
import json
http = httplib2.Http()
KEY = "AIzaSyBBPyJTesgJeCeXqTzOG7TxwAj1zkbVWOI"
CREATEAUTHURL_URI = "https://www.googleapis.com/rpc?key=%s"
VERIFYASSERTION_URI = "https://www.googleapis.com/identitytoolkit/v1/relyingparty/verifyAssertion?key=%s"
def create_auth_url(identifier="gmail.com", continueUrl="http://localhost:8080/cb"):
params = {"identifier": identifier,
"uiMode": "redirect",
"continueUrl": continueUrl}
data = [{"method": "identitytoolkit.relyingparty.createAuthUrl",
"id": "identitytoolkit.relyingparty.createAuthUrl",
"params": params,
"jsonrpc": "2.0",
"key": "identitytoolkit.relyingparty.createAuthUrl",
"apiVersion": "v1"}]
data = json.dumps(data)
resp, content = http.request(CREATEAUTHURL_URI % KEY,
method="POST",
body=data)
return str(json.loads(content)[0]["result"]["authUri"])
def verify_assertion(requestUri, postBody="", returnOauthToken=False):
# a full request uri -- including all the params.
assert isinstance(requestUri, str)
# a string postbody -- or just an empty string if this came from a GET
assert isinstance(postBody, str)
assert isinstance(returnOauthToken, bool)
data = {"requestUri": requestUri, "postBody": postBody, "returnOauthToken": returnOauthToken}
resp, content = http.request(VERIFYASSERTION_URI % KEY,
method="POST",
body=json.dumps(data))
return json.loads(content)