Hacker News new | past | comments | ask | show | jobs | submit login

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.



Sigaloid here (from the linked thread). 1. I can't believe I missed this thread! 2. this is amazing, I _just_ opened an issue looking into the GQL API, but you've done some great work here. I cannot thank you enough. This will help enormously! Hopefully we can prepare for the changes properly.


I also did a little digging on this in 2018, this api allows more granular api control.

There's cool little parameters like rich text element, and other RPAN generally not available to the normal api.


This may come in handy later, thank you.


A real shame indeed ;)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: