From 4d0dbb03b43984a802355834805c856f21c7d328 Mon Sep 17 00:00:00 2001 From: DDSRem <73049927+DDSRem@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:15:20 +0800 Subject: [PATCH] fix: data input --- aliyuntvtoken_connector/main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/aliyuntvtoken_connector/main.go b/aliyuntvtoken_connector/main.go index 69ef6e14b7..5d10af1063 100644 --- a/aliyuntvtoken_connector/main.go +++ b/aliyuntvtoken_connector/main.go @@ -59,9 +59,20 @@ func decrypt_AES256_CBC_PKCS7(ciphertext, key, iv string) (string, error) { func main() { http.HandleFunc("/oauth/alipan/token", func(w http.ResponseWriter, r *http.Request) { - body, _ := io.ReadAll(r.Body) - - refresh_token := gjson.Get(string(body), "refresh_token").String() + r.ParseForm() + refresh_token := r.FormValue("refresh_token") + if refresh_token == "" { + var body map[string]interface{} + err := json.NewDecoder(r.Body).Decode(&body) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if val, ok := body["refresh_token"]; ok { + refresh_token = val.(string) + } + } + fmt.Println(refresh_token) reqBodyJson := `{"refresh_token": "` + refresh_token + `"}` resp, err := http.Post("http://api.extscreen.com/aliyundrive/v2/token", "application/json", strings.NewReader(reqBodyJson))