TgSharp icon indicating copy to clipboard operation
TgSharp copied to clipboard

Login 2FA MakeAuthWithPasswordAsync method missing

Open TonySeedy opened this issue 4 years ago • 5 comments

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

TonySeedy avatar Jul 27 '21 19:07 TonySeedy

i need this method too

silemftooh avatar Nov 19 '21 07:11 silemftooh

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

atrdev-rgb avatar Nov 20 '21 20:11 atrdev-rgb

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

pahager avatar Jan 08 '22 16:01 pahager

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

atrdev-rgb avatar Jan 08 '22 19:01 atrdev-rgb

@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.

pahager avatar Jan 08 '22 20:01 pahager