mautrix-discord/remoteauth
2022-05-20 23:46:15 +03:00
..
client.go Add (dis|re)connect commands and provision api 2022-02-22 07:56:15 -06:00
clientpackets.go Initial discord remote auth support. 2022-01-04 20:20:45 -06:00
README.md Add pre-commit with CI and issue templates 2022-05-20 23:46:15 +03:00
serverpackets.go Add (dis|re)connect commands and provision api 2022-02-22 07:56:15 -06:00
user.go Initial discord remote auth support. 2022-01-04 20:20:45 -06:00

Discord Remote Authentication

This library implements the desktop side of Discord's remote authentication protocol.

It is completely based off of the Unofficial Discord API Documentation.

Example

package main

import (
	"context"
	"fmt"

	"github.com/skip2/go-qrcode"
)

func main() {
	client, err := New()
	if err != nil {
		fmt.Printf("error: %v\n", err)

		return
	}

	ctx := context.Background()

	qrChan := make(chan *qrcode.QRCode)
	go func() {
		qrCode := <-qrChan
		fmt.Println(qrCode.ToSmallString(true))
	}()

	doneChan := make(chan struct{})

	if err := client.Dial(ctx, qrChan, doneChan); err != nil {
		close(qrChan)
		close(doneChan)

		fmt.Printf("dial error: %v\n", err)

		return
	}

	<-doneChan

	user, err := client.Result()
	fmt.Printf("user: %q\n", user)
	fmt.Printf("err: %v\n", err)
}