|
| 1 | + |
| 2 | + |
| 3 | +class ClientApplication(object): |
| 4 | + DEFAULT_AUTHORITY = "https://login.microsoftonline.com/common/" |
| 5 | + TOKEN_ENDPOINT_PATH = '/oauth2/v2.0/token' |
| 6 | + |
| 7 | + def __init__( |
| 8 | + self, client_id, |
| 9 | + validate_authority=True, authority=DEFAULT_AUTHORITY): |
| 10 | + self.client_id = client_id |
| 11 | + self.validate_authority = validate_authority |
| 12 | + self.authority = authority |
| 13 | +# def aquire_token_silent( |
| 14 | +# self, scopes, user=None, authority=None, policy=None, |
| 15 | +# force_refresh=False): |
| 16 | +# pass |
| 17 | + |
| 18 | + |
| 19 | +class PublicClientApplication(ClientApplication): |
| 20 | + DEFAULT_REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob" |
| 21 | + |
| 22 | + def __init__(self, client_id, redirect_uri=DEFAULT_REDIRECT_URI, **kwargs): |
| 23 | + super(PublicClientApplication, self).__init__(client_id, **kwargs) |
| 24 | + self.redirect_uri = redirect_uri |
| 25 | + |
| 26 | +class ConfidentialClientApplication(ClientApplication): |
| 27 | + def __init__(self, client_id, client_credential, user_token_cache, **kwargs): |
| 28 | + """ |
| 29 | + :param client_credential: It can be a string containing client secret, |
| 30 | + or an X509 certificate object. |
| 31 | + """ |
| 32 | + super(ConfidentialClientApplication, self).__init__(client_id, **kwargs) |
| 33 | + self.client_credential = client_credential |
| 34 | + self.user_token_cache = user_token_cache |
| 35 | + self.app_token_cache = None # TODO |
| 36 | + |
| 37 | + def acquire_token_for_client(self, scope, policy=None): # Can policy default to None? |
| 38 | + pass |
| 39 | + |
0 commit comments