Use built in function for special FetchSessionKey
This commit is contained in:
parent
36ba50352a
commit
72862609c5
1 changed files with 3 additions and 1 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -198,7 +199,7 @@ func (c *Client) FetchSessionKey(privatekey string) error {
|
||||||
query := form.Encode()
|
query := form.Encode()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
req, err := c.newRequest(ctx, "POST", secretsPath+"/get-session-key/", "", query)
|
req, err := http.NewRequestWithContext(ctx, "POST", secretsPath+"/get-session-key/", strings.NewReader(query))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -213,6 +214,7 @@ func (c *Client) FetchSessionKey(privatekey string) error {
|
||||||
req.Header.Add("Authorization", " Token "+c.Token)
|
req.Header.Add("Authorization", " Token "+c.Token)
|
||||||
|
|
||||||
var sessionkey NetBoxSessionKey
|
var sessionkey NetBoxSessionKey
|
||||||
|
|
||||||
res, err := c.do(req, sessionkey)
|
res, err := c.do(req, sessionkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue