Skip to main content

auth.sendCode

Send the verification code for login

func (c *Client) AuthSendCode(ctx context.Context, request *AuthSendCodeRequest) (AuthSentCodeClass, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.AuthSendCode(ctx, &tg.AuthSendCodeRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // AuthSentCodeClass
return nil
})

Parameters

NameTypeRequiredDescription
PhoneNumberstringyesPhone number in international format
APIIDintyesApplication identifier (see App configuration)
APIHashstringyesApplication secret hash (see App configuration)
SettingsCodeSettingsyesSettings for the code type to send

Returns

AuthSentCodeClass

Possible errors

CodeTypeDescription
400API_ID_INVALIDAPI ID invalid.
400API_ID_PUBLISHED_FLOODThis API id was published somewhere, you can't use it now.
500AUTH_RESTARTRestart the authorization process.
400PHONE_NUMBER_APP_SIGNUP_FORBIDDENYou can't sign up using this app.
400PHONE_NUMBER_BANNEDThe provided phone number is banned from telegram.
400PHONE_NUMBER_FLOODYou asked for the code too many times.
406PHONE_NUMBER_INVALIDThe phone number is invalid.
406PHONE_PASSWORD_FLOODYou have tried logging in too many times.
400PHONE_PASSWORD_PROTECTEDThis phone is password protected.
400SMS_CODE_CREATE_FAILEDAn error occurred while creating the SMS code.
406UPDATE_APP_TO_LOGINPlease update your client to login.

References