Skip to content

Commit

Permalink
Add wrapper for /users/@me/remote-auth/login
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 13, 2022
1 parent 6445b63 commit 1c9f071
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions droid.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import (
)

const (
droidCapabilities = 509
droidCapabilities = 1021
droidOS = "Windows"
droidOSVersion = "10"
droidBrowser = "Chrome"
droidReferrer = "https://discord.com/channels/@me"
droidReferringDomain = "discord.com"
droidClientBuildNumber = "135402"
droidClientBuildNumber = "146284"
droidReleaseChannel = "stable"
droidStatus = "online"
droidSystemLocale = "en-US"
)

const (
DroidBrowserVersion = "103.0.5060.114"
DroidBrowserVersion = "105.0.0.0"
DroidBrowserUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + DroidBrowserVersion + " Safari/537.36"
)

Expand Down
2 changes: 2 additions & 0 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ var (
EndpointResetPassword = EndpointAuth + "reset"
EndpointRegister = EndpointAuth + "register"

EndpointRemoteAuthLogin = EndpointUsers + "@me/remote-auth/login"

EndpointVoiceIce = EndpointVoice + "ice"

EndpointTutorial = EndpointAPI + "tutorial/"
Expand Down
24 changes: 24 additions & 0 deletions restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,30 @@ func (s *Session) Login(email, password string) (err error) {
return
}

func (s *Session) RemoteAuthLogin(ticket string) (encryptedToken string, err error) {

data := struct {
Ticket string `json:"ticket"`
}{ticket}

response, err := s.RequestWithBucketID("POST", EndpointRemoteAuthLogin, data, EndpointRemoteAuthLogin)
if err != nil {
return
}

temp := struct {
EncryptedToken string `json:"encrypted_token"`
}{}

err = unmarshal(response, &temp)
if err != nil {
return
}

encryptedToken = temp.EncryptedToken
return
}

// Register sends a Register request to Discord, and returns the authentication token
// Note that this account is temporary and should be verified for future use.
// Another option is to save the authentication token external, but this isn't recommended.
Expand Down

0 comments on commit 1c9f071

Please sign in to comment.