Documentation ¶
Overview ¶
Package qrlogin provides QR login flow implementation.
Index ¶
- func AcceptQR(ctx context.Context, raw *tg.Client, t Token) (*tg.Authorization, error)
- type LoggedIn
- type MigrationNeededError
- type Options
- type QR
- func (q QR) Accept(ctx context.Context, t Token) (*tg.Authorization, error)
- func (q QR) Auth(ctx context.Context, loggedIn LoggedIn, ...) (*tg.AuthAuthorization, error)
- func (q QR) Export(ctx context.Context, exceptIDs ...int64) (Token, error)
- func (q QR) Import(ctx context.Context) (*tg.AuthAuthorization, error)
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LoggedIn ¶
type LoggedIn <-chan struct{}
LoggedIn is signal channel to notify about tg.UpdateLoginToken.
func OnLoginToken ¶
func OnLoginToken(d interface { OnLoginToken(tg.LoginTokenHandler) }) LoggedIn
OnLoginToken sets handler for given dispatcher and returns signal channel.
type MigrationNeededError ¶
type MigrationNeededError struct { MigrateTo *tg.AuthLoginTokenMigrateTo Tried bool }
MigrationNeededError reports that Telegram requested DC migration to continue login.
func (*MigrationNeededError) Error ¶
func (m *MigrationNeededError) Error() string
Error implements error.
type QR ¶
type QR struct {
// contains filtered or unexported fields
}
QR implements Telegram QR login flow.
func (QR) Accept ¶
Accept accepts given token.
See https://core.telegram.org/api/qr-login#accepting-a-login-token.
func (QR) Auth ¶
func (q QR) Auth( ctx context.Context, loggedIn LoggedIn, show func(ctx context.Context, token Token) error, exceptIDs ...int64, ) (*tg.AuthAuthorization, error)
Auth generates new QR login token, shows it and awaits acceptation.
NB: Show callback may be called more than once if QR expires.
func (QR) Export ¶
Export exports new login token.
See https://core.telegram.org/api/qr-login#exporting-a-login-token.
func (QR) Import ¶
Import imports accepted token.
See https://core.telegram.org/api/qr-login#confirming-importing-the-login-token.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token represents Telegram QR Login token.
func ParseTokenURL ¶
ParseTokenURL creates Token from given URL.
func (Token) URL ¶
URL returns login URL.
See https://core.telegram.org/api/qr-login#exporting-a-login-token.