Skip to content

Commit cf05444

Browse files
committed
Change the route prefixes
1 parent d8bbbc7 commit cf05444

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OAUTH2_CLIENT_ID=eccd08d6736b7999a32a
22
OAUTH2_CLIENT_SECRET=642999c1c5f2b3df8b877afdc78252ef5b594d31
3-
OAUTH2_CALLBACK_URL=http://127.0.0.1:8000/auth/callback
3+
OAUTH2_CALLBACK_URL=http://127.0.0.1:8000/oauth2/token
44
OAUTH2_REDIRECT_URL=http://127.0.0.1:8000/
55

66
JWT_SECRET=secret

fastapi_oauth2/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def get_token_data(
9898
params: Optional[Dict[str, Any]] = None,
9999
headers: Optional[Dict[str, Any]] = None,
100100
redirect_uri: Optional[str] = None,
101-
) -> Optional[dict]:
101+
) -> Optional[Dict[str, Any]]:
102102
params = params or {}
103103
additional_headers = headers or {}
104104
additional_headers.update(self.additional_headers or {})

fastapi_oauth2/router.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
OAUTH2_REDIRECT_URL,
1111
)
1212

13-
router = APIRouter()
13+
router = APIRouter(prefix="/oauth2")
1414
oauth2 = GitHubOAuth2(
1515
client_id=OAUTH2_CLIENT_ID,
1616
client_secret=OAUTH2_CLIENT_SECRET,
@@ -19,17 +19,17 @@
1919
)
2020

2121

22-
@router.get("/auth/login")
22+
@router.get("/login")
2323
async def login():
2424
return await oauth2.login_redirect()
2525

2626

27-
@router.get("/auth/callback")
28-
async def callback(request: Request):
27+
@router.get("/token")
28+
async def token(request: Request):
2929
return await oauth2.token_redirect(request)
3030

3131

32-
@router.get("/auth/logout")
32+
@router.get("/logout")
3333
async def logout():
3434
response = RedirectResponse(OAUTH2_REDIRECT_URL)
3535
response.delete_cookie("Authorization")

templates/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)