UPDATE: Outh2 google

This commit is contained in:
2026-03-30 16:13:00 +07:00
parent d3f128b284
commit 0410ae508e
21 changed files with 714 additions and 68 deletions

View File

@@ -70,6 +70,68 @@ const docTemplate = `{
}
}
},
"/auth/google/callback": {
"get": {
"description": "Receives the auth code from Google, exchanges it for tokens, creates/logs in the user, and redirects back to the frontend with application tokens.",
"tags": [
"Auth"
],
"summary": "Handle Google OAuth2 callback",
"parameters": [
{
"type": "string",
"description": "Security state string",
"name": "state",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Authorization code from Google",
"name": "code",
"in": "query",
"required": true
}
],
"responses": {
"302": {
"description": "Redirect to Frontend with JWTs",
"schema": {
"type": "string"
}
},
"401": {
"description": "Invalid state",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/auth/google/login": {
"get": {
"description": "Generates a state string, sets it in a cookie, and redirects the user to Google's consent page.",
"tags": [
"Auth"
],
"summary": "Initiate Google OAuth2 login",
"responses": {
"302": {
"description": "Redirect to Google",
"schema": {
"type": "string"
}
}
}
}
},
"/auth/refresh": {
"post": {
"security": [

View File

@@ -68,6 +68,68 @@
}
}
},
"/auth/google/callback": {
"get": {
"description": "Receives the auth code from Google, exchanges it for tokens, creates/logs in the user, and redirects back to the frontend with application tokens.",
"tags": [
"Auth"
],
"summary": "Handle Google OAuth2 callback",
"parameters": [
{
"type": "string",
"description": "Security state string",
"name": "state",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Authorization code from Google",
"name": "code",
"in": "query",
"required": true
}
],
"responses": {
"302": {
"description": "Redirect to Frontend with JWTs",
"schema": {
"type": "string"
}
},
"401": {
"description": "Invalid state",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/auth/google/login": {
"get": {
"description": "Generates a state string, sets it in a cookie, and redirects the user to Google's consent page.",
"tags": [
"Auth"
],
"summary": "Initiate Google OAuth2 login",
"responses": {
"302": {
"description": "Redirect to Google",
"schema": {
"type": "string"
}
}
}
}
},
"/auth/refresh": {
"post": {
"security": [

View File

@@ -207,6 +207,49 @@ paths:
summary: Handle forgotten password
tags:
- Auth
/auth/google/callback:
get:
description: Receives the auth code from Google, exchanges it for tokens, creates/logs
in the user, and redirects back to the frontend with application tokens.
parameters:
- description: Security state string
in: query
name: state
required: true
type: string
- description: Authorization code from Google
in: query
name: code
required: true
type: string
responses:
"302":
description: Redirect to Frontend with JWTs
schema:
type: string
"401":
description: Invalid state
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
summary: Handle Google OAuth2 callback
tags:
- Auth
/auth/google/login:
get:
description: Generates a state string, sets it in a cookie, and redirects the
user to Google's consent page.
responses:
"302":
description: Redirect to Google
schema:
type: string
summary: Initiate Google OAuth2 login
tags:
- Auth
/auth/refresh:
post:
consumes: