(pds string, refreshToken string)
| 62 | } |
| 63 | |
| 64 | func 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 | // |
nothing calls this directly
no test coverage detected