Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/ghunt/apis/fireconsolepa.py
253 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
from ghunt.parsers.clientauthconfig import CacBrand
6
7
import httpx
8
9
from typing import *
10
import inspect
11
import json
12
13
14
class FireconsolePaHttp(GAPI):
15
def __init__(self, creds: GHuntCreds, headers: Dict[str, str] = {}):
16
super().__init__()
17
18
if not headers:
19
headers = gb.config.headers
20
21
base_headers = {}
22
23
headers = {**headers, **base_headers}
24
25
self.hostname = "fireconsole-pa.clients6.google.com"
26
self.scheme = "https"
27
28
self._load_api(creds, headers)
29
30
async def is_project_valid(self, as_client: httpx.AsyncClient, project_identifier: str) -> Tuple[bool, CacBrand]:
31
"""
32
Returns if the given project identifier is valid.
33
The project identifier can be a project ID or a project number.
34
"""
35
endpoint = EndpointConfig(
36
name = inspect.currentframe().f_code.co_name,
37
verb = "POST",
38
data_type = "json", # json, data or None
39
authentication_mode = "sapisidhash", # sapisidhash, cookies_only, oauth or None
40
require_key = "firebase_console", # key name, or None
41
)
42
self._load_endpoint(endpoint)
43
44
base_url = "/v1/analytics:checkAccess"
45
46
params = {
47
"alt": "json"
48
}
49
50
post_data = {
51
"entityKey": {},
52
"firebaseProjectId": project_identifier
53
}
54
55
req = await self._query(endpoint.name, as_client, base_url, params=params, data=post_data)
56
57
return req.status_code != 404
58