+2
-9
atproto/client/admin_auth.go
+2
-9
atproto/client/admin_auth.go
···
3
3
import (
4
4
"encoding/base64"
5
5
"net/http"
6
-
7
-
"github.com/bluesky-social/indigo/atproto/syntax"
8
6
)
9
7
10
8
type AdminAuth struct {
···
16
14
return AdminAuth{basicAuthHeader: header}
17
15
}
18
16
19
-
func (a *AdminAuth) DoWithAuth(req *http.Request, httpClient *http.Client) (*http.Response, error) {
17
+
func (a *AdminAuth) DoWithAuth(c *http.Client, req *http.Request) (*http.Response, error) {
20
18
req.Header.Set("Authorization", a.basicAuthHeader)
21
-
return httpClient.Do(req)
22
-
}
23
-
24
-
// Admin bearer token auth does not involve an account DID
25
-
func (a *AdminAuth) AccountDID() syntax.DID {
26
-
return ""
19
+
return c.Do(req)
27
20
}
+1
-1
atproto/client/api_client.go
+1
-1
atproto/client/api_client.go
+1
-1
atproto/client/auth_method.go
+1
-1
atproto/client/auth_method.go
+1
-7
atproto/client/examples_test.go
+1
-7
atproto/client/examples_test.go
···
2
2
3
3
import (
4
4
"context"
5
-
"encoding/json"
6
5
"fmt"
7
6
8
7
appbsky "github.com/bluesky-social/indigo/api/bsky"
···
21
20
params := map[string]string{
22
21
"actor": "atproto.com",
23
22
}
24
-
b, err := c.Get(ctx, endpoint, params)
25
-
if err != nil {
26
-
panic(err)
27
-
}
28
-
29
23
var profile appbsky.ActorDefs_ProfileViewDetailed
30
-
if err := json.Unmarshal(*b, &profile); err != nil {
24
+
if err := c.Get(ctx, endpoint, params, &profile); err != nil {
31
25
panic(err)
32
26
}
33
27
+3
-3
atproto/client/refresh_auth.go
+3
-3
atproto/client/refresh_auth.go
···
24
24
// TODO:
25
25
//func NewRefreshAuth(pdsHost, accountIdentifier, password string) (*RefreshAuth, error) {
26
26
27
-
func (a *RefreshAuth) DoWithAuth(req *http.Request, c *http.Client) (*http.Response, error) {
27
+
func (a *RefreshAuth) DoWithAuth(c *http.Client, req *http.Request) (*http.Response, error) {
28
28
req.Header.Set("Authorization", "Bearer "+a.AccessToken)
29
29
// XXX: check response. if it is 403, because access token is expired, then take a lock and do a refresh
30
30
// TODO: when doing a refresh request, copy at least the User-Agent header from httpReq, and re-use httpClient
31
-
return c.Do(httpReq)
31
+
return c.Do(req)
32
32
}
33
33
34
34
// updates the client with the new auth method
···
49
49
}
50
50
51
51
if out.Active != nil && *out.Active == false {
52
-
return nil, fmt.Errorf("account is disabled: %s", out.Status)
52
+
return nil, fmt.Errorf("account is disabled: %v", out.Status)
53
53
}
54
54
55
55
ra := RefreshAuth{