Tulir Asokan 704bdaefd7 Update to remote auth v2 2 năm trước cách đây
..
README.md bd03e80b52 Add pre-commit with CI and issue templates 3 năm trước cách đây
client.go 704bdaefd7 Update to remote auth v2 2 năm trước cách đây
clientpackets.go 2055d32da8 Run gofmt 2 năm trước cách đây
serverpackets.go 704bdaefd7 Update to remote auth v2 2 năm trước cách đây
user.go 94104102d2 Initial discord remote auth support. 3 năm trước cách đây

README.md

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)
}