Compare commits
No commits in common. "84535cb5a7597df20779526d42ee7c65ed7b0cc9" and "bafb502147f8e3d657bd8032e0dd0cd0051e4756" have entirely different histories.
84535cb5a7
...
bafb502147
2 changed files with 4 additions and 11 deletions
|
|
@ -118,14 +118,8 @@ func (bluesky *Bluesky) RefreshSession() error {
|
||||||
func (bluesky *Bluesky) CheckSessionValid() {
|
func (bluesky *Bluesky) CheckSessionValid() {
|
||||||
resp := new(BSkySessionResponse)
|
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)).
|
bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT)).
|
||||||
Get("/xrpc/app.bsky.actor.getProfile").QueryStruct(params).Receive(resp, resp)
|
Get("/xrpc/app.bsky.actor.getProfile").Receive(resp, resp)
|
||||||
if resp.Error == "ExpiredToken" {
|
if resp.Error == "ExpiredToken" {
|
||||||
bluesky.RefreshSession()
|
bluesky.RefreshSession()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import (
|
||||||
|
|
||||||
type BSky struct {
|
type BSky struct {
|
||||||
Bluesky *Bluesky
|
Bluesky *Bluesky
|
||||||
DID string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBSky() *BSky {
|
func NewBSky() *BSky {
|
||||||
|
|
@ -105,10 +104,10 @@ func (b *BSky) GetPDS(handle string) string {
|
||||||
func (b *BSky) Auth(authData []string) error {
|
func (b *BSky) Auth(authData []string) error {
|
||||||
b.Bluesky.Cfg.Handle = authData[0]
|
b.Bluesky.Cfg.Handle = authData[0]
|
||||||
b.getPDS()
|
b.getPDS()
|
||||||
auth, _ := loadAuth()
|
auth, err := loadAuth()
|
||||||
if auth == nil || auth.AccessJWT == "" { // no auth session found
|
if err != nil { // no auth session found
|
||||||
b.Bluesky.Cfg.AppPassword = authData[1]
|
b.Bluesky.Cfg.AppPassword = authData[1]
|
||||||
err := b.Bluesky.CreateSession(b.Bluesky.Cfg)
|
err = b.Bluesky.CreateSession(b.Bluesky.Cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to auth: %s", err)
|
return fmt.Errorf("unable to auth: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue