It would be a real shame if libreddit were to log the requests made by the Android app and try to replicate them, using this code to sign the "x-hmac-signed-body" and "x-hmac-signed-result" headers in the https://accounts.reddit.com/api/login request.
func (c *Client) generateResultData(epoch int64) string {
return fmt.Sprintf("Epoch:%d|User-Agent:%s|Client-Vendor-ID:%s", epoch, c.userAgent, c.clientVendorID)
}
func (c *Client) generateBodyData(epoch int64, body []byte) string {
return fmt.Sprintf("Epoch:%d|Body:%s", epoch, string(body))
}
func hmacSignData(data string) string {
digester := hmac.New(sha256.New, []byte(REDDIT_ANDROID_HMAC_SECRET))
digester.Write([]byte(data))
return hex.EncodeToString(digester.Sum(nil))
}
REDDIT_ANDROID_OAUTH_CLIENT_ID = "ohXpoqrZYub1kg"
REDDIT_ANDROID_HMAC_SECRET = "8c7abaa5f905f70400c81bf3a1a101e75f7210104b1991f0cd5240aa80c4d99d"
And then use: https://oauth.reddit.com/r/%s/about.json
https://oauth.reddit.com/r/%s/top.json
https://oauth.reddit.com/search.json
etc.