-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.go
More file actions
26 lines (22 loc) · 798 Bytes
/
token.go
File metadata and controls
26 lines (22 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package d1http
import (
"context"
"net/http"
)
type TokenVerifyResult struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
NotBefore string `json:"not_before,omitempty"`
ExpiresOn string `json:"expires_on,omitempty"`
Policies []any `json:"policies,omitempty"`
}
func (c *Client) VerifyAccountToken(ctx context.Context) (*TokenVerifyResult, error) {
var env envelope[TokenVerifyResult]
err := c.do(ctx, http.MethodGet, apiPath("accounts", c.cfg.AccountID, "tokens/verify"), nil, nil, &env)
return &env.Result, err
}
func (c *Client) VerifyUserToken(ctx context.Context) (*TokenVerifyResult, error) {
var env envelope[TokenVerifyResult]
err := c.do(ctx, http.MethodGet, apiPath("user/tokens/verify"), nil, nil, &env)
return &env.Result, err
}