Skip to content
Snippets Groups Projects
Commit 3baf904d authored by Alexander Kovalev's avatar Alexander Kovalev
Browse files

Merge branch 'wistia-use-headers-0.26' into 'release/v0.26'

wistia: use headers for authetnication

See merge request mashroom/backend/account!67
parents 0457a895 3dd7b776
Branches release/v0.26
No related merge requests found
......@@ -3,6 +3,7 @@ package service
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strconv"
......@@ -20,7 +21,6 @@ func (srv *serviceImpl) listWistiaVideos(
) (videos []*model.WistiaVideo, err error) {
q := srv.config.Wistia.URL.Query()
q.Set("access_token", srv.config.Wistia.AccessToken)
q.Set("project_id", strconv.FormatInt(int64(projectID), 10))
q.Set("type", "Video")
......@@ -32,6 +32,8 @@ func (srv *serviceImpl) listWistiaVideos(
return nil, err
}
req.Header.Set("Authorization", "Bearer "+srv.config.Wistia.AccessToken)
resp, err := srv.config.Wistia.HTTPClient.Do(req)
if err != nil {
return
......@@ -41,11 +43,12 @@ func (srv *serviceImpl) listWistiaVideos(
_ = resp.Body.Close()
}()
body, err := ioutil.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {
return nil, errBadHTTPResponseStatus
return nil, fmt.Errorf("%w: %s", errBadHTTPResponseStatus, string(body))
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment