1
+ """Class to allow authentication on the Monzo API."""
1
2
import logging
2
3
import os
3
4
from pathlib import Path , PurePath
@@ -21,6 +22,7 @@ class Authentication(object):
21
22
Class provides methods to authenticate to the Monzo API and to make relevant queries. An instantiated
22
23
copy of this class is usually passed to each action
23
24
"""
25
+
24
26
__slots__ = [
25
27
'_access_token' ,
26
28
'_access_token_expiry' ,
@@ -41,7 +43,7 @@ def __init__(
41
43
refresh_token : str = ''
42
44
):
43
45
"""
44
- Standard init .
46
+ Initialize Authentication .
45
47
46
48
Args:
47
49
client_id: Client ID generated at https://developers.monzo.com
@@ -83,9 +85,7 @@ def authenticate(self, authorization_token: str, state_token: str) -> None:
83
85
self ._exchange_token (authorization_token = authorization_token )
84
86
85
87
def logout (self ) -> None :
86
- """
87
- Invalidates the access token.
88
- """
88
+ """Invalidate the access token."""
89
89
logging .debug ('Invalidating token' )
90
90
self .make_request (path = '/oauth2/logout' )
91
91
@@ -99,7 +99,7 @@ def make_request(
99
99
timeout : int = DEFAULT_TIMEOUT
100
100
) -> REQUEST_RESPONSE_TYPE :
101
101
"""
102
- Makes an API call to Monzo.
102
+ Make an API call to Monzo.
103
103
104
104
Args:
105
105
path: Path for the API call
@@ -212,7 +212,7 @@ def refresh_token(self) -> str:
212
212
@property
213
213
def state_token (self ) -> str :
214
214
"""
215
- Generates or returns a previously generated state token.
215
+ Generate or returns a previously generated state token.
216
216
217
217
Returns:
218
218
A state token used for authentication requests.
@@ -255,7 +255,7 @@ def _exchange_token(self, authorization_token: str) -> None:
255
255
256
256
def _populate_tokens (self , response : REQUEST_RESPONSE_TYPE ) -> None :
257
257
"""
258
- Populates tokens after a token request.
258
+ Populate tokens after a token request.
259
259
260
260
Args:
261
261
response: Response from an auth request.
@@ -278,7 +278,7 @@ def _populate_tokens(self, response: REQUEST_RESPONSE_TYPE) -> None:
278
278
279
279
def register_callback_handler (self , handler : Storage ) -> None :
280
280
"""
281
- Registers a new callback handler for handling new token details.
281
+ Register a new callback handler for handling new token details.
282
282
283
283
Args:
284
284
handler: Credential handler implementing Storage
0 commit comments