@ -46,3 +46,13 @@ class AuthenticatedClient(Client):
|
||||
def get_headers(self) -> Dict[str, str]:
|
||||
"""Get headers to be used in authenticated endpoints"""
|
||||
return {"Authorization": f"Bearer {self.token}", **self.headers}
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class AuthenticatedClientFromEnv(Client):
|
||||
"""A Client which has been authenticated for use on secured endpoints that uses the KITTYCAD_API_TOKEN environment variable for the authentication token."""
|
||||
|
||||
token: str = attr.ib(default=os.getenv('KITTYCAD_API_TOKEN'))
|
||||
|
||||
def get_headers(self) -> Dict[str, str]:
|
||||
"""Get headers to be used in authenticated endpoints"""
|
||||
return {"Authorization": f"Bearer {self.token}", **self.headers}
|
||||
|
Reference in New Issue
Block a user