From d4909eaad41e1c018220c275d694d409ac320589 Mon Sep 17 00:00:00 2001 From: astravexton Date: Sun, 12 Oct 2025 11:44:04 +0100 Subject: [PATCH 1/2] Fix CheckSessionValid function --- bluesky.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bluesky.go b/bluesky.go index 263df53..bdfb497 100644 --- a/bluesky.go +++ b/bluesky.go @@ -118,8 +118,14 @@ func (bluesky *Bluesky) RefreshSession() error { func (bluesky *Bluesky) CheckSessionValid() { resp := new(BSkySessionResponse) + params := struct { + Actor string `url:"actor"` + }{ + Actor: bluesky.Cfg.Handle, + } + bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT)). - Get("/xrpc/app.bsky.actor.getProfile").Receive(resp, resp) + Get("/xrpc/app.bsky.actor.getProfile").QueryStruct(params).Receive(resp, resp) if resp.Error == "ExpiredToken" { bluesky.RefreshSession() } From 84535cb5a7597df20779526d42ee7c65ed7b0cc9 Mon Sep 17 00:00:00 2001 From: astravexton Date: Sun, 12 Oct 2025 11:45:10 +0100 Subject: [PATCH 2/2] Fix auth --- client.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 545f6c6..9aa3472 100644 --- a/client.go +++ b/client.go @@ -15,6 +15,7 @@ import ( type BSky struct { Bluesky *Bluesky + DID string } func NewBSky() *BSky { @@ -104,10 +105,10 @@ func (b *BSky) GetPDS(handle string) string { func (b *BSky) Auth(authData []string) error { b.Bluesky.Cfg.Handle = authData[0] b.getPDS() - auth, err := loadAuth() - if err != nil { // no auth session found + auth, _ := loadAuth() + if auth == nil || auth.AccessJWT == "" { // no auth session found b.Bluesky.Cfg.AppPassword = authData[1] - err = b.Bluesky.CreateSession(b.Bluesky.Cfg) + err := b.Bluesky.CreateSession(b.Bluesky.Cfg) if err != nil { return fmt.Errorf("unable to auth: %s", err) }