github.com/clerkinc/clerk-sdk-go@v1.49.1/clerk/actor_tokens.go (about) 1 package clerk 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "net/http" 7 ) 8 9 type ActorTokenService service 10 11 type ActorTokenResponse struct { 12 Object string `json:"object"` 13 ID string `json:"id"` 14 UserID string `json:"user_id"` 15 Actor json.RawMessage `json:"actor"` 16 Token string `json:"token,omitempty"` 17 URL *string `json:"url,omitempty"` 18 Status string `json:"status"` 19 CreatedAt int64 `json:"created_at"` 20 UpdatedAt int64 `json:"updated_at"` 21 } 22 23 type CreateActorTokenParams struct { 24 UserID string `json:"user_id"` 25 Actor json.RawMessage `json:"actor"` 26 ExpiresInSeconds *int `json:"expires_in_seconds"` 27 SessionMaxDurationInSeconds *int `json:"session_max_duration_in_seconds"` 28 } 29 30 func (s *ActorTokenService) Create(params CreateActorTokenParams) (*ActorTokenResponse, error) { 31 req, _ := s.client.NewRequest(http.MethodPost, ActorTokensUrl, ¶ms) 32 33 var actorTokenResponse ActorTokenResponse 34 _, err := s.client.Do(req, &actorTokenResponse) 35 if err != nil { 36 return nil, err 37 } 38 return &actorTokenResponse, nil 39 } 40 41 func (s *ActorTokenService) Revoke(actorTokenID string) (*ActorTokenResponse, error) { 42 req, _ := s.client.NewRequest(http.MethodPost, fmt.Sprintf("%s/%s/revoke", ActorTokensUrl, actorTokenID)) 43 44 var actorTokenResponse ActorTokenResponse 45 _, err := s.client.Do(req, &actorTokenResponse) 46 if err != nil { 47 return nil, err 48 } 49 return &actorTokenResponse, nil 50 }