Package-Level Type Names (total 18, in which 13 are exported)
/* sort exporteds by: | */
Client implements Telegram authentication.api*tg.ClientappHashstringappIDintrandio.Reader AcceptTOS accepts version of Terms Of Service. Bot performs bot authentication request. CancelPasswordReset cancels password reset.
See https://core.telegram.org/api/srp#password-reset. IfNecessary runs given auth flow if current session is not authorized. Password performs login via secure remote password (aka 2FA).
Method can be called after SignIn to provide password if requested. ResetPassword resets cloud password and returns time to wait until reset be performed.
If time is zero, password was successfully reset.
May return ResetFailedWaitError.
See https://core.telegram.org/api/srp#password-reset. SendCode requests code for provided phone number, returning code hash
and error if any. Use AuthFlow to reduce boilerplate.
This method should be called first in user authentication flow. SignIn performs sign in with provided user phone, code and code hash.
If ErrPasswordAuthNeeded is returned, call Password to provide 2FA
password.
To obtain codeHash, use SendCode. SignUp registers a validated phone number in the system.
To obtain codeHash, use SendCode.
Use AuthFlow helper to handle authentication flow. Status gets authorization status of client. Test creates and runs auth flow using Test authenticator
if current session is not authorized. TestUser creates and runs auth flow using TestUser authenticator
if current session is not authorized. UpdatePassword sets new cloud password for this account.
See https://core.telegram.org/api/srp#setting-a-new-2fa-password. self returns current user.
You can use tg.User.Bot to check whether current user is bot.
*Client : FlowClient
func NewClient(api *tg.Client, rand io.Reader, appID int, appHash string) *Client
func github.com/gotd/td/telegram.(*Client).Auth() *Client
ResetFailedWaitError reports that you recently requested a password reset that was cancel and need to wait until the
specified date before requesting another reset.Resulttg.AccountResetPasswordFailedWait Error implements error. Until returns time required to wait.
*ResetFailedWaitError : error
SendCodeOptions defines how to send auth code to user. If a token that will be included in eventually sent SMSs is required:
required in newer versions of android, to use the android SMS receiver APIs. AllowFlashCall allows phone verification via phone calls. Pass true if the phone number is used on the current device.
Ignored if AllowFlashCall is not set.
func NewFlow(auth UserAuthenticator, opt SendCodeOptions) Flow
func (*Client).SendCode(ctx context.Context, phone string, options SendCodeOptions) (tg.AuthSentCodeClass, error)
func FlowClient.SendCode(ctx context.Context, phone string, options SendCodeOptions) (tg.AuthSentCodeClass, error)
Status represents authorization status. Authorized is true if client is authorized. User is current User object.
func (*Client).Status(ctx context.Context) (*Status, error)
UpdatePasswordOptions is options structure for UpdatePassword. Hint is new password hint. Password is password callback.
If password was requested and Password is nil, ErrPasswordNotProvided error will be returned.
func (*Client).UpdatePassword(ctx context.Context, newPassword string, opts UpdatePasswordOptions) error
Package-Level Functions (total 12, in which 11 are exported)
CodeOnly creates UserAuthenticator with constant phone and no password.
Constant creates UserAuthenticator with constant phone and password.
Env creates UserAuthenticator which gets phone and password from environment variables.
IsKeyUnregistered reports whether err is AUTH_KEY_UNREGISTERED error.
Deprecated: use IsUnauthorized.
IsUnauthorized reports whether err is 401 UNAUTHORIZED.
https://core.telegram.org/api/errors#401-unauthorized
NewClient initializes and returns Telegram authentication client.
NewFlow initializes new authentication flow.
NewPasswordHash computes new password hash to update password.
Notice that NewPasswordHash mutates given alg.
See https://core.telegram.org/api/srp#setting-a-new-2fa-password.
PasswordHash computes password hash to log in.
See https://core.telegram.org/api/srp#checking-the-password-with-srp.
Test returns UserAuthenticator that authenticates via testing credentials.
Can be used only with testing server. Will perform sign up if test user is
not registered.
TestUser returns UserAuthenticator that authenticates via testing credentials.
Uses given phone to sign in/sign up.
Can be used only with testing server. Will perform sign up if test user is
not registered.
checkResult checks that `a` is *tg.AuthAuthorization and returns authorization result or error.
Package-Level Variables (total 4, in which 3 are exported)
ErrPasswordAuthNeeded means that 2FA auth is required.
Call Client.Password to provide 2FA password.
ErrPasswordInvalid means that password provided to Password is invalid.
Note that telegram does not trim whitespace characters by default, check
that provided password is expected and clean whitespaces if needed.
You can use strings.TrimSpace(password) for this.
ErrPasswordNotProvided means that password requested by Telegram,
but not provided by user.
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.