1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

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

This commit is contained in:
Frédéric Guillot 2025-07-22 21:07:22 -07:00
parent 202de7c787
commit 1d1162327e

View file

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