Answer the question
In order to leave comments, you need to log in
How to pass authorization and send Get to yandex disk api?
There is an Api token, if you add it to the header of a regular get request, net / http swears at the wrong header.
How to log in and send a request to Yandex.Disk api?
I do it like this:
client := &http.Client{}
req, err := http.NewRequest(
"GET", "https://cloud-api.yandex.net/v1/disk", nil,
)
req.Header.Add("Authorization: OAuth", "Сам токен")
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
Answer the question
In order to leave comments, you need to log in
client := &http.Client{}
req, err := http.NewRequest(
"GET", "https://cloud-api.yandex.net/v1/disk", nil,
)
req.Header.Add("Authorization", "токен")
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question