MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / RefreshToken

Function RefreshToken

bluesky/auth.go:64–87  ·  view source on GitHub ↗
(pds string, refreshToken string)

Source from the content-addressed store, hash-verified

62}
63
64func RefreshToken(pds string, refreshToken string) (*AuthResponse, error) {
65 url := pds + "/xrpc/com.atproto.server.refreshSession"
66
67 resp, err := SendRequest(&refreshToken, http.MethodPost, url, nil)
68 if err != nil {
69 return nil, err
70 }
71 defer resp.Body.Close()
72
73 if resp.StatusCode != http.StatusOK {
74 bodyBytes, _ := io.ReadAll(resp.Body)
75 bodyString := string(bodyBytes)
76 fmt.Println("Response Status:", resp.StatusCode)
77 fmt.Println("Response Body:", bodyString)
78 return nil, errors.New("reauth failed")
79 }
80
81 var authResp AuthResponse
82 if err := json.NewDecoder(resp.Body).Decode(&authResp); err != nil {
83 return nil, err
84 }
85
86 return &authResp, nil
87}
88
89// This function is to get: the user DID and the user's PDS this should **ONLY** be used during authentication.
90//

Callers

nothing calls this directly

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected