Remind before LinkedIn's sign-in expires, and stop posting once it has

LinkedIn tokens last 60 days and can't be renewed without signing in
again. The expiry LinkedIn reports is now recorded (60 days from sign-in
for older connections). The LinkedIn card says until when; from two
weeks before, the Overview, the Inbox and the card remind you, with a
Reconnect button. Once expired, LinkedIn counts as not connected, due
posts come back to the Inbox saying why, and a 401 from LinkedIn reads
"reconnect LinkedIn" instead of the raw error.

Also fixes a leftover "Settings → Credentials" in a publish error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 11:43:59 -07:00
co-authored by Claude Opus 5.5
parent a2c8889599
commit 9c62680927
14 changed files with 159 additions and 9 deletions
+8
View File
@@ -3,6 +3,7 @@ package linkedin
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@@ -69,6 +70,9 @@ func (c *Client) PostUpdate(ctx context.Context, text, sourceURL string) (string
defer res.Body.Close()
raw, _ := io.ReadAll(res.Body)
if res.StatusCode == http.StatusUnauthorized {
return "", ErrUnauthorized
}
if res.StatusCode != http.StatusCreated {
return "", fmt.Errorf("linkedin HTTP %d: %s", res.StatusCode, raw)
}
@@ -81,6 +85,10 @@ func (c *Client) PostUpdate(ctx context.Context, text, sourceURL string) (string
}
// GetAuthorURN fetches the LinkedIn person URN for the owner of accessToken.
// ErrUnauthorized is LinkedIn refusing the access token, usually because it
// expired (they last 60 days and can't be renewed without signing in again).
var ErrUnauthorized = errors.New("LinkedIn refused the sign-in; it has probably expired: reconnect LinkedIn under Settings → Social accounts")
func GetAuthorURN(ctx context.Context, accessToken string) (string, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, apiBase+"/v2/userinfo", nil)
if err != nil {