2023-03-09 17:47:33 +00:00
|
|
|
from hatchway import QueryOrBody, api_view
|
2022-12-11 04:03:14 +00:00
|
|
|
|
2023-07-15 18:37:34 +00:00
|
|
|
from api import schemas
|
|
|
|
from api.decorators import scope_required
|
|
|
|
from api.models import Application
|
2022-12-11 04:03:14 +00:00
|
|
|
|
|
|
|
|
2023-02-07 19:07:15 +00:00
|
|
|
@api_view.post
|
2023-03-09 17:47:33 +00:00
|
|
|
def add_app(
|
|
|
|
request,
|
|
|
|
client_name: QueryOrBody[str],
|
|
|
|
redirect_uris: QueryOrBody[str],
|
|
|
|
scopes: QueryOrBody[None | str] = None,
|
|
|
|
website: QueryOrBody[None | str] = None,
|
|
|
|
) -> schemas.Application:
|
2023-05-04 04:42:37 +00:00
|
|
|
application = Application.create(
|
|
|
|
client_name=client_name,
|
2023-03-09 17:47:33 +00:00
|
|
|
website=website,
|
|
|
|
redirect_uris=redirect_uris,
|
2023-05-04 04:42:37 +00:00
|
|
|
scopes=scopes,
|
2022-12-11 04:03:14 +00:00
|
|
|
)
|
2023-07-15 18:37:34 +00:00
|
|
|
return schemas.Application.from_application(application)
|
|
|
|
|
|
|
|
|
|
|
|
@scope_required("read")
|
|
|
|
@api_view.get
|
|
|
|
def verify_credentials(
|
|
|
|
request,
|
|
|
|
) -> schemas.Application:
|
|
|
|
return schemas.Application.from_application_no_keys(request.token.application)
|