change query param refresh token to body request

This commit is contained in:
renaldybrada
2026-02-20 09:14:46 +07:00
parent 2ca3cf3564
commit c64f46ce82
5 changed files with 63 additions and 14 deletions
+17 -4
View File
@@ -512,11 +512,13 @@ const docTemplate = `{
"summary": "Requesting new token to keycloak using refresh token",
"parameters": [
{
"type": "string",
"description": "Valid Refresh Token",
"name": "refresh_token",
"in": "query",
"required": true
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/keycloak.RefreshTokenRequest"
}
}
],
"responses": {
@@ -1276,6 +1278,17 @@ const docTemplate = `{
}
}
},
"keycloak.RefreshTokenRequest": {
"type": "object",
"required": [
"refresh_token"
],
"properties": {
"refresh_token": {
"type": "string"
}
}
},
"pasien.PasienResponse": {
"type": "object",
"properties": {
+17 -4
View File
@@ -506,11 +506,13 @@
"summary": "Requesting new token to keycloak using refresh token",
"parameters": [
{
"type": "string",
"description": "Valid Refresh Token",
"name": "refresh_token",
"in": "query",
"required": true
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/keycloak.RefreshTokenRequest"
}
}
],
"responses": {
@@ -1270,6 +1272,17 @@
}
}
},
"keycloak.RefreshTokenRequest": {
"type": "object",
"required": [
"refresh_token"
],
"properties": {
"refresh_token": {
"type": "string"
}
}
},
"pasien.PasienResponse": {
"type": "object",
"properties": {
+11 -3
View File
@@ -325,6 +325,13 @@ definitions:
- published
type: string
type: object
keycloak.RefreshTokenRequest:
properties:
refresh_token:
type: string
required:
- refresh_token
type: object
pasien.PasienResponse:
properties:
alamat:
@@ -749,10 +756,11 @@ paths:
post:
parameters:
- description: Valid Refresh Token
in: query
name: refresh_token
in: body
name: body
required: true
type: string
schema:
$ref: '#/definitions/keycloak.RefreshTokenRequest'
responses:
"200":
description: OK
+13 -3
View File
@@ -3,6 +3,7 @@ package keycloak
import (
"net/http"
"antrian-operasi/internal/shared"
baseResponse "antrian-operasi/internal/shared"
"github.com/gin-gonic/gin"
@@ -19,13 +20,22 @@ func NewKeycloakHandler(service IKeycloakService) KeycloakHandler {
// GetTokenByRefreshCode godoc
// @Summary Requesting new token to keycloak using refresh token
// @Tags Keycloak
// @Param refresh_token query string true "Valid Refresh Token"
// @Param body body RefreshTokenRequest true "Valid Refresh Token"
// @Success 200 {object} shared.BaseResponse
// @Failure 500 {object} shared.BaseErrorResponse
// @Router /keycloak/refresh-token [post]
func (h KeycloakHandler) GetTokenByRefreshCode(c *gin.Context) {
refreshToken := c.Query("refresh_token")
resp, err := h.service.FetchTokenUsingRefreshToken(c, refreshToken)
var req RefreshTokenRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(400, shared.BaseErrorResponse{
Success: false,
Code: 400,
Message: "error bind json",
Errors: shared.ValidationError(err),
})
return
}
resp, err := h.service.FetchTokenUsingRefreshToken(c, req.RefreshToken)
if err != nil {
errorResponse := baseResponse.BaseErrorResponse{
+5
View File
@@ -0,0 +1,5 @@
package keycloak
type RefreshTokenRequest struct {
RefreshToken string `json:"refresh_token" binding:"required"`
}