1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 18:32:29 +01:00

oapi: oauth2

This commit is contained in:
Puyodead1 2023-03-24 21:43:18 -04:00
parent 3a40254ca5
commit 1b1fbce4d3
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC
5 changed files with 3744 additions and 98 deletions

View File

@ -6134,6 +6134,17 @@
"stickers"
]
},
"OAuthAuthorizeResponse": {
"type": "object",
"properties": {
"location": {
"type": "string"
}
},
"required": [
"location"
]
},
"TenorTrendingResponse": {
"type": "object",
"properties": {
@ -7762,10 +7773,56 @@
}
},
"responses": {
"default": {
"description": "No description available"
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OAuthAuthorizeResponse"
}
}
}
},
"400": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIErrorResponse"
}
}
}
},
"403": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIErrorResponse"
}
}
}
},
"404": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIErrorResponse"
}
}
}
}
},
"parameters": [
{
"name": "client_id",
"in": "query",
"schema": {
"type": "string"
}
}
],
"tags": [
"oauth2"
]

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,21 @@ const router = Router();
// TODO: scopes, other oauth types
router.get("/", route({}), async (req: Request, res: Response) => {
router.get(
"/",
route({
responses: {
// TODO: I really didn't feel like typing all of it out
200: {},
400: {
body: "APIErrorResponse",
},
404: {
body: "APIErrorResponse",
},
},
}),
async (req: Request, res: Response) => {
// const { client_id, scope, response_type, redirect_url } = req.query;
const { client_id } = req.query;
@ -56,7 +70,13 @@ router.get("/", route({}), async (req: Request, res: Response) => {
id: req.user_id,
bot: false,
},
select: ["id", "username", "avatar", "discriminator", "public_flags"],
select: [
"id",
"username",
"avatar",
"discriminator",
"public_flags",
],
});
const guilds = await Member.find({
@ -131,11 +151,33 @@ router.get("/", route({}), async (req: Request, res: Response) => {
},
authorized: false,
});
});
},
);
router.post(
"/",
route({ requestBody: "ApplicationAuthorizeSchema" }),
route({
requestBody: "ApplicationAuthorizeSchema",
query: {
client_id: {
type: "string",
},
},
responses: {
200: {
body: "OAuthAuthorizeResponse",
},
400: {
body: "APIErrorResponse",
},
403: {
body: "APIErrorResponse",
},
404: {
body: "APIErrorResponse",
},
},
}),
async (req: Request, res: Response) => {
const body = req.body as ApplicationAuthorizeSchema;
// const { client_id, scope, response_type, redirect_url } = req.query;

View File

@ -0,0 +1,3 @@
export interface OAuthAuthorizeResponse {
location: string;
}

View File

@ -31,6 +31,7 @@ export * from "./GuildWidgetJsonResponse";
export * from "./GuildWidgetSettingsResponse";
export * from "./LocationMetadataResponse";
export * from "./MemberJoinGuildResponse";
export * from "./OAuthAuthorizeResponse";
export * from "./Tenor";
export * from "./TokenResponse";
export * from "./UserProfileResponse";