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 -1
View File
@@ -228,6 +228,7 @@ type connectInfo struct {
Account string
At time.Time
Note string
Expiry *Expiry // when the sign-in runs out, for LinkedIn
}
func (s *Server) accountsPage(w http.ResponseWriter, r *http.Request) {
@@ -272,6 +273,7 @@ func (s *Server) networks() []network {
case "LinkedIn":
n.Connect = connect("linkedin", secrets.LinkedInAccessToken, "In your LinkedIn app's Auth settings, add this redirect URL:", "",
set[secrets.LinkedInClientID] && set[secrets.LinkedInClientSecret], func(string) string { return "" })
n.Connect.Expiry = s.linkedInExpiry()
case "Reddit":
n.Connect = connect("reddit", secrets.RedditAccessToken, "At reddit.com/prefs/apps, create a web app with this redirect URI:",
"Reddit's API terms need approval for commercial use: Supermarket is meant for a few hand-approved posts, not volume.",
@@ -444,7 +446,12 @@ func (s *Server) oauthCallback(w http.ResponseWriter, r *http.Request) {
fail("Signed in, but couldn't save the token: " + err.Error())
return
}
if err := s.saveConnection("linkedin", Connection{Account: urn, At: time.Now()}); err != nil {
life := res.ExpiresIn
if life <= 0 {
life = linkedInTokenLife
}
now := time.Now()
if err := s.saveConnection("linkedin", Connection{Account: urn, At: now, Expires: now.Add(life)}); err != nil {
s.Log.Error("saving connection", "err", err)
}
redirect(w, r, "/settings/accounts", "li-connected")