Skip to content

Commit c1d0167

Browse files
committed
Move BearerAuth to own file
1 parent a27ca1c commit c1d0167

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .bearer_auth import BearerAuth
2+
3+
__all__ = ["BearerAuth"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import httpx
2+
3+
class BearerAuth(httpx.Auth):
4+
def __init__(self, token: str):
5+
self.token = token
6+
7+
def auth_flow(self, request):
8+
request.headers['Authorization'] = f"Bearer {self.token}"
9+
yield request
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from .server_client import ServerClient
2+
from .my_account_client import MyAccountClient
23

3-
__all__ = ["ServerClient"]
4+
__all__ = ["ServerClient", "MyAccountClient"]

src/auth0_server_python/auth_server/my_account_client.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import httpx
3-
3+
from auth0_server_python.auth_schemes.bearer_auth import BearerAuth
44
from auth0_server_python.auth_types import (
55
ConnectAccountRequest,
66
ConnectAccountResponse,
@@ -100,12 +100,4 @@ async def complete_connect_account(
100100
"connect_account_error",
101101
f"Connected Accounts complete request failed: {str(e) or 'Unknown error'}",
102102
e
103-
)
104-
105-
class BearerAuth(httpx.Auth):
106-
def __init__(self, token: str):
107-
self.token = token
108-
109-
def auth_flow(self, request):
110-
request.headers['Authorization'] = f"Bearer {self.token}"
111-
yield request
103+
)

0 commit comments

Comments
 (0)