nblockchain / TgSharp

Telegram client library implemented in C#
32 stars 12 forks source link

Login 2FA MakeAuthWithPasswordAsync method missing #50

Open TonySeedy opened 3 years ago

TonySeedy commented 3 years ago

Hello everyone I did not found MakeAuthWithPasswordAsync method I cant login 2fa without AuthPassword Did you change it or move it to another class that I can't find? i tried change like TLSharp version but it doesn't work in TG

silemftooh commented 3 years ago

i need this method too

atrdev-rgb commented 3 years ago

https://github.com/nblockchain/TgSharp/tree/2faFeature

pahager commented 2 years ago

Did you find a solution how to use 2FA Auth?

atrdev-rgb commented 2 years ago

try { await RequestWithDcMigration(request, token).ConfigureAwait(false); } catch (CloudPasswordNeededException ex) { if (password != "") { requestCheckPassword = new TLRequestCheckPassword { Password = await SRPHelper.CheckPassword(this, password, token) }; await RequestWithDcMigration(requestCheckPassword, token).ConfigureAwait(false); } else throw ex; }

        if (requestCheckPassword == null && request.Response is TLAuthorization)
        {
            OnUserAuthenticated(((TLUser)((TLAuthorization)request.Response).User));
            return ((TLUser)((TLAuthorization)request.Response).User);
        }
        else if (requestCheckPassword != null && requestCheckPassword.Response is TLAuthorization)
        {
            OnUserAuthenticated(((TLUser)((TLAuthorization)requestCheckPassword.Response).User));
            return ((TLUser)((TLAuthorization)requestCheckPassword.Response).User);
        }
        else
        {
            var signUpRequest = new TLRequestSignUp() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, FirstName = firstName, LastName = lastName };
            await RequestWithDcMigration(signUpRequest, token).ConfigureAwait(false);
            OnUserAuthenticated((TLUser)signUpRequest.Response.User);
            return (TLUser)signUpRequest.Response.User;
        }
pahager commented 2 years ago

@atrezonator Thx, for your answer. Do I need to paste this in MakeAuthAsync Method or I need to create new MakeAuthWithPasswordAsync Method and paste this code? Btw. TgSharp does not have SRPHelper Class.