Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/ghunt/apis/accounts.py
252 views
1
from ghunt.objects.base import GHuntCreds
2
from ghunt.errors import *
3
import ghunt.globals as gb
4
from ghunt.objects.apis import GAPI, EndpointConfig
5
6
import httpx
7
8
from typing import *
9
import inspect
10
11
12
class Accounts(GAPI):
13
def __init__(self, creds: GHuntCreds, headers: Dict[str, str] = {}):
14
super().__init__()
15
16
if not headers:
17
headers = gb.config.headers
18
19
base_headers = {}
20
21
headers = {**headers, **base_headers}
22
23
# Android OAuth fields
24
self.api_name = "chrome"
25
self.package_name = "com.android.chrome"
26
self.scopes = [
27
"https://www.google.com/accounts/OAuthLogin"
28
]
29
30
self.hostname = "accounts.google.com"
31
self.scheme = "https"
32
33
self.authentication_mode = "oauth" # sapisidhash, cookies_only, oauth or None
34
self.require_key = None # key name, or None
35
36
self._load_api(creds, headers)
37
38
async def OAuthLogin(self, as_client: httpx.AsyncClient) -> str:
39
endpoint = EndpointConfig(
40
name = inspect.currentframe().f_code.co_name,
41
verb = "GET",
42
data_type = None, # json, data or None
43
authentication_mode = "oauth", # sapisidhash, cookies_only, oauth or None
44
require_key = None, # key name, or None
45
key_origin = None
46
)
47
self._load_endpoint(endpoint)
48
49
base_url = f"/OAuthLogin"
50
params = {
51
"source": "ChromiumBrowser",
52
"issueuberauth": 1
53
}
54
55
req = await self._query(endpoint.name, as_client, base_url, params)
56
57
# Parsing
58
uber_auth = req.text
59
60
return True, uber_auth
61