changes in token: GWM
This commit is contained in:
parent
9b46e38a7e
commit
b470f9cd63
2
.env
2
.env
@ -5,7 +5,7 @@ BASE_URL = https://pb.venbait.in
|
|||||||
|
|
||||||
UAEPASS_TOKEN_API = https://stg-id.uaepass.ae/idshub/token
|
UAEPASS_TOKEN_API = https://stg-id.uaepass.ae/idshub/token
|
||||||
UAEPASS_TOKEN_API_PARAM_GRANT_TYPE = authorization_code
|
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_USERNAME = sandbox_stage
|
||||||
UAEPASS_TOKEN_API_AUTHORIZATION_PASSWORD = sandbox_stage
|
UAEPASS_TOKEN_API_AUTHORIZATION_PASSWORD = sandbox_stage
|
||||||
|
|
||||||
|
|||||||
58
main.go
58
main.go
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
firebase "firebase.google.com/go"
|
firebase "firebase.google.com/go"
|
||||||
"firebase.google.com/go/messaging"
|
"firebase.google.com/go/messaging"
|
||||||
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
@ -1827,7 +1828,30 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer tokenResp.Body.Close()
|
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 {
|
var tokenResult struct {
|
||||||
AccessToken string `json:"access_token"`
|
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{}{
|
return c.JSON(http.StatusOK, map[string]interface{}{
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"message": "User found by UUID",
|
"message": "User found by UUID",
|
||||||
"token": token,
|
"token": token,
|
||||||
"data": userDetails,
|
"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{}{
|
return c.JSON(http.StatusOK, map[string]interface{}{
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"message": "User found by email and UUID updated",
|
"message": "User found by email and UUID updated",
|
||||||
"token": token2,
|
"token": token2,
|
||||||
"data": userDetails,
|
"data": userByEmail,
|
||||||
|
"expiresOn": exp,
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
BIN
pb_data/data.db
BIN
pb_data/data.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user