summaryrefslogtreecommitdiff
path: root/internal/platforms/linkedin/oauth2
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-17 22:03:10 +0200
committerPaul Buetow <paul@buetow.org>2026-02-17 22:03:10 +0200
commit5f53f241189af3fceb26395af383809cd4fa3bf0 (patch)
tree4ffabc358ec85ed1da425f72e1357e80f340b2c1 /internal/platforms/linkedin/oauth2
parenta8cb28d2257cff652fc4f8a9768b66b9d69fd68a (diff)
fix: improve LinkedIn API posting and authenticationv1.2.4
- Add token validation before using cached credentials to prevent stale token issues - Add proper error handling for image upload initialization with helpful 426 messages - Skip data URI images instead of attempting to download them - Update default LinkedIn API version to 202601 (January 2026) - latest active version - Fix re-authentication flow for expired tokens Amp-Thread-ID: https://ampcode.com/threads/T-019c6d28-4526-7738-b593-9bd584baa478 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/platforms/linkedin/oauth2')
-rw-r--r--internal/platforms/linkedin/oauth2/oauth2.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/platforms/linkedin/oauth2/oauth2.go b/internal/platforms/linkedin/oauth2/oauth2.go
index 8fe25ab..45cb9b7 100644
--- a/internal/platforms/linkedin/oauth2/oauth2.go
+++ b/internal/platforms/linkedin/oauth2/oauth2.go
@@ -93,7 +93,13 @@ func oauthCallbackHandler(w http.ResponseWriter, r *http.Request) {
func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error) {
conf := args.Config
if conf.LinkedInAccessToken != "" && conf.LinkedInPersonID != "" {
- return conf.LinkedInPersonID, conf.LinkedInAccessToken, nil
+ // Validate cached token before using it
+ token := &oauth2.Token{AccessToken: conf.LinkedInAccessToken}
+ if _, err := getOauthPersonID(token); err == nil {
+ return conf.LinkedInPersonID, conf.LinkedInAccessToken, nil
+ }
+ // Cached token is invalid, clear it to trigger re-auth
+ conf.LinkedInAccessToken = ""
}
oauthConfig = &oauth2.Config{