antonio-antuan / rust-tdlib

Rust client for TDlib
MIT License
57 stars 11 forks source link

Having trouble with authorization flow [windows] #35

Closed moonstripe closed 1 year ago

moonstripe commented 1 year ago

I'm trying to reproduce some of the functions I have working on MacOS, but I'm getting the following error:

[2023-09-07T22:35:01Z WARN  rust_tdlib::client::worker] error received and possibly cannot be handled because of empty state receiver for client 1: Error { extra: Some("9317c4f9-99e0-499f-98e4-7eb076969d4f"), client_id: Some(1), code: 400, message: "Valid api_id must be provided. Can be obtained at https://my.telegram.org" }

Seems like the tdlib_params aren't being set properly, because when I set the verbosity level to 3, I see the following tdlib_params being sent:

[ 3][t 5][1694126101.514971256][Td.cpp:2966][#1][!Td][&td_requests]     Receive request 2: setTdlibParameters {
  use_test_dc = false
  database_directory = ""
  files_directory = ""
  database_encryption_key = bytes [0] { }
  use_file_database = false
  use_chat_info_database = false
  use_message_database = false
  use_secret_chats = false
  api_id = 0
  api_hash = ""
  system_language_code = ""
  device_model = ""
  system_version = ""
  application_version = ""
  enable_storage_optimizer = false
  ignore_file_names = false
}

Here's the code I'm using (essentially the same as on docs.rs):

    let mut worker = Worker::builder().build().unwrap();
    let waiter = worker.start();
    let tdlib_params = TdlibParameters::builder().api_id(var("API_ID").unwrap().parse::<i32>().unwrap()).api_hash(var("API_HASH").unwrap()).build();
    let client = rust_tdlib::client::Client::builder().with_tdlib_parameters(tdlib_params).build().unwrap();

    log::info!("Client {:#?}", client);

    log::info!("Worker {:#?}", worker);

    let client = worker.bind_client(client).await.unwrap();
    let me = client.get_me(GetMe::builder().build()).await.unwrap();
    println!("{:?}", me);

I've checked that the environmental variables are set and retrieved correctly.

moonstripe commented 1 year ago

Perhaps it's an issue with my build of tdlib?

[ 3][t 5][1694126101.512905836][Td.cpp:4060][#1][!Td][&td_requests]     Sending update: updateOption {
  name = "version"
  value = optionValueString {
    value = "1.8.17"
  }
}
antonio-antuan commented 1 year ago

I'm not familiar with windows development. What if instead of passing it from environment variables you try to specify those parameters explicitly hardcoded in your code?

moonstripe commented 1 year ago

Just tried it hard-coded. Same issue.

Looks like others have fixed it in the Python version by reverting it to 1.8.0?

https://github.com/tdlib/td/issues/2285

antonio-antuan commented 1 year ago

I'd say yes the reason is that. Especially because the lib currently supports only 1.8.0 :) I can provide support for a newer one, but I'm on vacation now and this is the first time in my life when I'm on vacation without laptop)) So I can dive into it not earlier than in a couple of weeks

moonstripe commented 1 year ago

Hey hey, no rush! Hopefully reverting the build will help!

I'll update this issue if it works!

Thanks as always for your speedy responses!

moonstripe commented 1 year ago

Works when I build the 1.8.0 version of TDLib!

Closing!