-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
/api/v1/authorize
endpoint.
- Loading branch information
Showing
11 changed files
with
134 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from attrs import frozen | ||
from typing_extensions import Self | ||
from melody.shared.converter import CONVERTER | ||
|
||
from melody.shared.typing import Data | ||
|
||
__all__ = ("AuthorizationCode", "AuthorizationCodeData") | ||
|
||
|
||
class AuthorizationCodeData(Data): | ||
code: str | ||
state: str | ||
|
||
|
||
@frozen() | ||
class AuthorizationCode: | ||
code: str | ||
state: str | ||
|
||
@classmethod | ||
def from_data(cls, data: AuthorizationCodeData) -> Self: | ||
return CONVERTER.structure(data, cls) | ||
|
||
def into_data(self) -> AuthorizationCodeData: | ||
return CONVERTER.unstructure(self) # type: ignore[no-any-return] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from fastapi import Depends, Form | ||
from typing_extensions import Annotated | ||
|
||
from melody.shared.tokens import Scopes | ||
|
||
__all__ = ( | ||
# dependencies | ||
"ScopesDependency", | ||
# dependables | ||
"scopes_dependency", | ||
) | ||
|
||
FormScopeDependency = Annotated[str, Form()] | ||
|
||
|
||
def scopes_dependency(scope: FormScopeDependency) -> Scopes: | ||
return Scopes.from_scope(scope) | ||
|
||
|
||
ScopesDependency = Annotated[Scopes, Depends(scopes_dependency)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters