Skip to content

Commit

Permalink
feat(api): use Authorization Bearer
Browse files Browse the repository at this point in the history
resolved #206
  • Loading branch information
SevereCloud committed Jul 16, 2022
1 parent 548b3cc commit 4e5e665
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ func buildQuery(sliceParams ...Params) (context.Context, url.Values) {

for _, params := range sliceParams {
for key, value := range params {
if key != ":context" {
query.Set(key, FmtValue(value, 0))
} else {
switch key {
case "access_token":
continue
case ":context":
ctx = value.(context.Context)
default:
query.Set(key, FmtValue(value, 0))
}
}
}
Expand Down Expand Up @@ -255,6 +258,9 @@ func (vk *VK) DefaultHandler(method string, sliceParams ...Params) (Response, er
acceptEncoding = "zstd"
}

token := sliceParams[len(sliceParams)-1]["access_token"].(string)
req.Header.Set("Authorization", "Bearer "+token)

req.Header.Set("User-Agent", vk.UserAgent)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

Expand Down

0 comments on commit 4e5e665

Please sign in to comment.