Last active
March 11, 2023 21:36
-
-
Save sim642/225c44801a376e2c54e746285d4c680f to your computer and use it in GitHub Desktop.
Reddit Chat (via SendBird) reverse engineering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as request from "request"; | |
import * as SendBird from "sendbird"; | |
const sendbirdServiceUrl = "https://sendbird.reddit.com"; | |
const sendbirdAppId = "2515BDA8-9D3A-47CF-9325-330BC37ADA13"; | |
const userId = "t2_mv8j9bt"; // chatrev1 | |
const accessToken = "49777998329-oof4CSA1jedsnu6pXgJj_SFIk7o"; | |
// accessToken (bearer): | |
// full (personalized) oauth2 access token (from web/installed reddit app): user id base 10 - oauth2 access token | |
// 49777998329-H9hcJ0dWF73yFI24LRdxzzBhUp8 | |
// 49777998329-oof4CSA1jedsnu6pXgJj_SFIk7o | |
// partial (unpersonalized) oauth2 access tokens (from script reddit app) don't work | |
// -oof4CSA1jedsnu6pXgJj_SFIk7o | |
const sendbirdServiceRequest = request.defaults({ | |
baseUrl: sendbirdServiceUrl, | |
auth: { | |
bearer: accessToken | |
}, | |
json: true | |
}); | |
sendbirdServiceRequest("/api/v1/sendbird/me", (err, res, body) => { | |
const sbAccessToken = body.sb_access_token; | |
console.log(sbAccessToken); | |
sendbirdServiceRequest("/api/v1/sendbird/config", (err, res, body) => { | |
const proxyHost = body.proxy_host; | |
console.log(proxyHost); | |
let sb = new SendBird({ | |
appId: sendbirdAppId | |
}); | |
sb.connect(userId, sbAccessToken, "https://" + proxyHost, "wss://" + proxyHost, (user, error) => { | |
console.log(user); | |
sb.GroupChannel.createMyGroupChannelListQuery().next((channelList, error) => { | |
console.log(channelList); | |
// let channel = channelList[0]; | |
// channel.sendUserMessage("Test", (message, error) => { | |
// console.log(message); | |
// }); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment