Browse Source

feat(integration): use Bearer token authorization instead of cookie for Linkwarden client

Frédéric Guillot 11 tháng trước cách đây
mục cha
commit
1d1162327e
1 tập tin đã thay đổi với 4 bổ sung16 xóa
  1. 4 16
      internal/integration/linkwarden/linkwarden.go

+ 4 - 16
internal/integration/linkwarden/linkwarden.go

@@ -35,12 +35,9 @@ func (c *Client) CreateBookmark(entryURL, entryTitle string) error {
 		return fmt.Errorf(`linkwarden: invalid API endpoint: %v`, err)
 	}
 
-	requestBody, err := json.Marshal(&linkwardenBookmark{
-		Url:         entryURL,
-		Name:        entryTitle,
-		Description: "",
-		Tags:        []string{},
-		Collection:  map[string]any{},
+	requestBody, err := json.Marshal(map[string]string{
+		"url":  entryURL,
+		"name": entryTitle,
 	})
 
 	if err != nil {
@@ -54,8 +51,7 @@ func (c *Client) CreateBookmark(entryURL, entryTitle string) error {
 
 	request.Header.Set("Content-Type", "application/json")
 	request.Header.Set("User-Agent", "Miniflux/"+version.Version)
-	request.AddCookie(&http.Cookie{Name: "__Secure-next-auth.session-token", Value: c.apiKey})
-	request.AddCookie(&http.Cookie{Name: "next-auth.session-token", Value: c.apiKey})
+	request.Header.Set("Authorization", "Bearer "+c.apiKey)
 
 	httpClient := &http.Client{Timeout: defaultClientTimeout}
 	response, err := httpClient.Do(request)
@@ -70,11 +66,3 @@ func (c *Client) CreateBookmark(entryURL, entryTitle string) error {
 
 	return nil
 }
-
-type linkwardenBookmark struct {
-	Url         string         `json:"url"`
-	Name        string         `json:"name"`
-	Description string         `json:"description"`
-	Tags        []string       `json:"tags"`
-	Collection  map[string]any `json:"collection"`
-}