22from typing import Any , Dict , List , Optional , Union
33
44from .calls import make_request
5- from .data import AuthType , BugoutToken , BugoutUser , BugoutUserTokens , Method , TokenType
5+ from .data import (
6+ AuthType ,
7+ BugoutToken ,
8+ BugoutUser ,
9+ BugoutUserTokens ,
10+ BugoutUserWithGroups ,
11+ Method ,
12+ TokenType ,
13+ )
614from .exceptions import InvalidUrlSpec , TokenInvalidParameters
7- from .settings import REQUESTS_TIMEOUT , BUGOUT_APPLICATION_ID_HEADER
15+ from .settings import BUGOUT_APPLICATION_ID_HEADER , REQUESTS_TIMEOUT
816
917
1018class User :
@@ -26,6 +34,20 @@ def _call(self, method: Method, path: str, **kwargs):
2634 return result
2735
2836 # User module
37+ def auth (
38+ self ,
39+ token : Union [str , uuid .UUID ],
40+ auth_type : AuthType = AuthType .bearer ,
41+ ** kwargs : Dict [str , Any ],
42+ ) -> BugoutUserWithGroups :
43+ headers = {
44+ "Authorization" : f"{ auth_type .value } { token } " ,
45+ }
46+ if "headers" in kwargs .keys ():
47+ headers .update (kwargs ["headers" ])
48+ result = self ._call (method = Method .get , path = "auth" , headers = headers )
49+ return BugoutUserWithGroups (** result )
50+
2951 def create_user (
3052 self ,
3153 username : Optional [str ] = None ,
0 commit comments