gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

RPCError: 400: NEW_PASSWORD_BAD (caused by account.UpdatePasswordSettings)

Open hieumi01k63 opened this issue 2 years ago • 2 comments

I'm trying to create new 2FA (2 Factor Authentication) password via "Api.account.UpdatePasswordSettings". But I ran into this error: image

Here is my code: (the client has already connected) const result: Api.Bool = await client.invoke( new Api.account.UpdatePasswordSettings({ password: new Api.InputCheckPasswordEmpty(), newSettings: new Api.account.PasswordInputSettings({ newAlgo: resPass.newAlgo, newPasswordHash: Buffer.from(password), hint: hint, email: recoverEmail, newSecureSettings: new Api.SecureSecretSettings({ secureAlgo: resPass.newSecureAlgo, secureSecret: Buffer.from(hint), secureSecretId: BigInt(-4156887774564), }), }), }) ); image

I also have a issue with typescript in "secureSecretId" field: Type 'bigint' is not assignable to type 'BigInteger'. The expected type comes from property 'secureSecretId' which is declared here on type '{ secureAlgo: TypeSecurePasswordKdfAlgo; secureSecret: Buffer; secureSecretId: BigInteger; }'

Any ideal?

hieumi01k63 avatar Sep 22 '22 12:09 hieumi01k63

Update:

  • I have now fixed the typescript error by replace "BigInt(-4156887774564)" to "bigInt("-4156887774564")". But i still get the same error "RPCError: 400: NEW_PASSWORD_BAD" over and over again.
  • Also, "resPass" is the password obj returned by Api.account.GetPassword().

hieumi01k63 avatar Sep 23 '22 04:09 hieumi01k63

there is already a helper method that does that, you should use it instead since it's a bit more complicated. https://gram.js.org/beta/classes/TelegramClient.html#updateTwoFaSettings

painor avatar Sep 23 '22 08:09 painor

Wow, finally it works. I didn't know there is a helper for this. Thanks man, you made my day.

hieumi01k63 avatar Sep 26 '22 01:09 hieumi01k63