changes in token: GWM

This commit is contained in:
Gowtham M 2025-11-25 14:43:44 +05:30
parent 9b46e38a7e
commit b470f9cd63
7 changed files with 62 additions and 10 deletions

2
.env
View File

@ -5,7 +5,7 @@ BASE_URL = https://pb.venbait.in
UAEPASS_TOKEN_API = https://stg-id.uaepass.ae/idshub/token
UAEPASS_TOKEN_API_PARAM_GRANT_TYPE = authorization_code
UAEPASS_TOKEN_API_PARAM_REDIRECTION_URL = http://localhost:60876
UAEPASS_TOKEN_API_PARAM_REDIRECTION_URL = http://localhost:55227
UAEPASS_TOKEN_API_AUTHORIZATION_USERNAME = sandbox_stage
UAEPASS_TOKEN_API_AUTHORIZATION_PASSWORD = sandbox_stage

70
main.go
View File

@ -23,6 +23,7 @@ import (
firebase "firebase.google.com/go"
"firebase.google.com/go/messaging"
"github.com/golang-jwt/jwt/v4"
"github.com/joho/godotenv"
"github.com/labstack/echo/v5"
"github.com/pocketbase/dbx"
@ -1827,7 +1828,30 @@ func main() {
}
defer tokenResp.Body.Close()
tokenBody, _ := ioutil.ReadAll(tokenResp.Body)
// tokenBody, _ := ioutil.ReadAll(tokenResp.Body)
fmt.Println("---------- UAEPASS TOKEN API DEBUG ----------")
fmt.Println("Token API URL:", tokenURL)
fmt.Println("grant_type:", os.Getenv("UAEPASS_TOKEN_API_PARAM_GRANT_TYPE"))
fmt.Println("redirect_uri:", os.Getenv("UAEPASS_TOKEN_API_PARAM_REDIRECTION_URL"))
fmt.Println("code:", reqData.Code)
fmt.Println("BasicAuth Username:", os.Getenv("UAEPASS_TOKEN_API_AUTHORIZATION_USERNAME"))
fmt.Println("BasicAuth Password:", os.Getenv("UAEPASS_TOKEN_API_AUTHORIZATION_PASSWORD"))
fmt.Println("Status Code:", tokenResp.StatusCode)
tokenBodyBytes, err := ioutil.ReadAll(tokenResp.Body)
tokenBody := tokenBodyBytes
if err != nil {
fmt.Println("Error reading token response body:", err)
} else {
fmt.Println("Raw Token API Response:", string(tokenBodyBytes))
}
fmt.Println("--------------------------------------------")
var tokenResult struct {
AccessToken string `json:"access_token"`
@ -1890,11 +1914,25 @@ func main() {
})
}
// Extract exp from PB token
parsed, _, err := new(jwt.Parser).ParseUnverified(token, jwt.MapClaims{})
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]interface{}{
"status": "error",
"message": "Failed to decode token",
"error": err.Error(),
})
}
claims := parsed.Claims.(jwt.MapClaims)
exp := claims["exp"]
return c.JSON(http.StatusOK, map[string]interface{}{
"status": "success",
"message": "User found by UUID",
"token": token,
"data": userDetails,
"status": "success",
"message": "User found by UUID",
"token": token,
"data": user,
"expiresOn": exp,
})
}
@ -1931,11 +1969,25 @@ func main() {
})
}
// Extract exp from PB token
parsed, _, err := new(jwt.Parser).ParseUnverified(token2, jwt.MapClaims{})
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]interface{}{
"status": "error",
"message": "Failed to decode token",
"error": err.Error(),
})
}
claims := parsed.Claims.(jwt.MapClaims)
exp := claims["exp"]
return c.JSON(http.StatusOK, map[string]interface{}{
"status": "success",
"message": "User found by email and UUID updated",
"token": token2,
"data": userDetails,
"status": "success",
"message": "User found by email and UUID updated",
"token": token2,
"data": userByEmail,
"expiresOn": exp,
})
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File