-
I seem to always get this error message "rpc error code 401: AUTH_KEY_UNREGISTERED" even after specifying my APP_ID and HASH_ID in the NewClient(). appId := os.Getenv("TELEGRAM_APP_ID") I don't know where I could be getting it wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Not to worry, I have moved passed this error. |
Beta Was this translation helpful? Give feedback.
-
sorry for bumping this up, but can I ask how ? |
Beta Was this translation helpful? Give feedback.
-
I can't remember exactly what I did anymore since it has been a while now. But this is a part of the code that I'm sure solved the issue. I hope it helps. ctx := context.Background()
appID, _ := strconv.Atoi(os.Getenv("TELEGRAM_APP_ID"))
appHash := os.Getenv("TELEGRAM_APP_HASH")
phoneNumber := os.Getenv("TELEGRAM_PHONE_NUMBER")
client := telegram.NewClient(appID, appHash, telegram.Options{})
if err := client.Run(ctx, func(ctx context.Context) error {
sendCode, sendCodeErr := client.Auth().SendCode(ctx, phoneNumber, auth.SendCodeOptions{})
if sendCodeErr != nil {
fmt.Printf("This is the error from the send code: %v\n", sendCodeErr)
}
fmt.Printf("Please input the code sent to you...\n")
var textCode string
fmt.Scan(&textCode)
_, signInErr := client.Auth().SignIn(ctx, phoneNumber, textCode, sendCode.PhoneCodeHash)
if signInErr != nil {
fmt.Printf("This is the error from the signin: %v\n", signInErr)
}
fmt.Printf("Moving to input password...\n")
var pass string
fmt.Scan(&pass)
passAuth, passAuthErr := client.Auth().Password(ctx, pass)
if passAuthErr != nil {
fmt.Printf("This is the error from the signin password: %v\n", passAuthErr)
}
fmt.Printf("This is the authorization response: %v\n", passAuth)
//Authentication stops here
fmt.Printf("Client is running...\n")
api := client.API()
fmt.Print(api)
return nil
}); err != nil {
fmt.Printf("Client error: %v", err)
} |
Beta Was this translation helpful? Give feedback.
I can't remember exactly what I did anymore since it has been a while now. But this is a part of the code that I'm sure solved the issue. I hope it helps.
cc @lsy88 @AndreJorgeLopes