我正在 golang 中做這個,我幾乎整夜都在努力讓它工作。我最近的挫敗感是,盡管我在請求中放入了大量標頭,但還是收到了 400 錯誤。 29 req.SetBasicAuth(app.id, app.secret) 30 req.Header.Set("Host", "www.sandbox.paypal.com") 31 req.Header.Set("Accept", "application/json") 32 req.Header.Set("Accept-Language", "en_US") 33 req.Header.Set("Content-Type", "application/x-www-form-urlencoded") 34 req.Header.Set("Connection", "close")我已經設置了身份驗證,以及我想添加的每個標題。我仔細研究了文檔并嘗試了戳它,看看它是否也有效。這是我通過 post 請求傳遞到正文中的信息`{"grant_type": "client_credentials"}` 42 req, err := http.NewRequest( 43 "POST", 44 app.Endpoint + oauthEndpoint, 45 strings.NewReader(`{"grant_type": "client_credentials"}`), 46 )如果您需要更多代碼,請告訴我。但我不太確定它會很好。我也想讓這篇文章盡可能通用。編輯:因此,盡管我在有效負載中手動指定了 grant_type ,但它似乎失敗了,因為grant_type沒有被識別{"error":"invalid_request","error_description":"grant_type is a required parameter"}
- 2 回答
- 0 關注
- 219 瀏覽
添加回答
舉報
0/150
提交
取消