remoteauth

package
v0.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex

	URL string
	// contains filtered or unexported fields
}

func New

func New() (*Client, error)

New creates a new Discord remote auth client. qrChan is a channel that will receive the qrcode once it is available.

func (*Client) Dial

func (c *Client) Dial(ctx context.Context, qrChan chan string, doneChan chan struct{}) error

Dial will start the QRCode login process. ctx may be used to abandon the process.

func (*Client) Result

func (c *Client) Result() (User, error)

type User

type User struct {
	UserID        string
	Discriminator string
	AvatarHash    string
	Username      string

	Token string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL