I try to build a bot for website. My idea for bot with a lot of functions which do some actions with website and first action is login by password and save session.
I create a login function which calling from main and get login and password as input data. Then I send post request with login. Then I get cookie from response and return this. But how should I apply cookies in order to use them in other functions and so that the site perceives me as an authorized user because the data format in which I return cookies cannot be substituted in the header, in any case, I did not get success
func main() {
cookie := login("test", "test")
fmt.Println(cookie)
func login(email, password string) (cookie []*http.Cookie) {
loginLink := "https://oskelly.ru/api/v2/account/rawauth"
jar, _ := cookiejar.New(nil)
client := http.Client{Jar: jar}
resp, _ := client.PostForm(loginLink, url.Values{"rawEmail": {email}, "rawPassword": {password}})
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
cookie = resp.Cookies()
return cookie