forked from frontegg/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontegg.py
53 lines (39 loc) · 1.58 KB
/
frontegg.py
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
44
45
46
47
48
49
50
51
52
53
from typing import Optional
from frontegg.common import FronteggAuthenticator, IdentityClientMixin
from frontegg.common.frontegg_context import FronteggContext
class Frontegg:
def __init__(self):
self.authenticator: FronteggAuthenticator = None
self.identity_client: IdentityClientMixin = None
def init_app(self, client_id: str, api_key: str, options={}):
FronteggContext.init(options)
self.authenticator = FronteggAuthenticator(client_id, api_key)
self.identity_client = IdentityClientMixin(self.authenticator)
@property
def should_refresh_vendor_token(self) -> bool:
return self.authenticator.should_refresh_vendor_token
@property
def access_token(self):
return self.authenticator.access_token
def refresh_vendor_token(self) -> None:
self.authenticator.refresh_vendor_token()
@property
def client_id(self):
return frontegg.authenticator.client_id
@property
def api_key(self):
return frontegg.authenticator.api_key
def get_public_key(self) -> str:
return self.identity_client.get_public_key()
def fetch_public_key(self) -> str:
return self.identity_client.fetch_public_key()
def validate_identity_on_token(
self,
token,
options,
type,
):
return self.identity_client.validate_identity_on_token(token, options, type)
def decode_jwt(self, authorization_header, verify: Optional[bool] = True):
return self.identity_client.decode_jwt(authorization_header, verify)
frontegg = Frontegg()