Closed aaravinfosoft closed 8 years ago
Check your phone number, try to reset session.dat file
Hello @sochix ,
I have try by remove session.dat and also check phone number by (+) sign and without, but not work.
I have also try below code and its working fine and return "TRUE"
var result = await tgClient.IsPhoneRegistered(TGAUserPhoneNumber);
But once try to send message on that number, its not working.
Can you please provide any other solution ?
I still checking and still not working it.
Regards, Rupendra
In code you provided you Connect
and than instantly check IsAuthorized
. Do you call SendCode
and MakeAuth
?
library updated
Hi
I created and connected (ConnectAsync
), sent the code and authed (MakeAuthAsync
) this function successfully returned the TLUser
object, also IsUserAuthorized
returns true. At this time everything is ok and e.g. SendMessageAsync
sends messages like a charm.
Now if I close the program and start it again, despite IsUserAuthorized
return true, but SendMessageAsync
throws a AUTH_KEY_UNREGISTERED
.
I tried deleting session.dat and tried authentication multiple times but the result is the same.
Hi, i have same problem, but occurs before send message. The 'AUTH_KEY_UNREGISTERED' is on client.GetsContactsAsync()' I already test:
ia am using a translated to VBNET from C# Testt.vs at github.
Public Overridable Async Function SendMessage(Msg As String) As Task
**'NumberToSendMessage is set at main source code and is CHECKED ok**
If String.IsNullOrWhiteSpace(NumberToSendMessage) Then
Throw New Exception($"Please fill the '{NameOf(NumberToSendMessage)}' setting in app.config file first")
End If
' this is because the contacts in the address come without the "+" prefix
Dim normalizedNumber = If(NumberToSendMessage.StartsWith("+"), NumberToSendMessage.Substring(1, NumberToSendMessage.Length - 1), NumberToSendMessage)
**' OK - Newclient returns valid value**
Dim client = NewClient()
**' OK - Connected is true**
Dim connected As Boolean = Await client.ConnectAsync()
If connected Then ' pass test
If client.IsUserAuthorized() Then ' pass test
Dim result As Contacts.TLContacts
Try **' Code changed to get the error**
result = Await client.GetContactsAsync()
Catch ex As Exception **' here occurs error AUTH_KEY_UNREGISTERED**
Throw New Exception($"Please fill the '{NameOf(NumberToSendMessage)}' getting contact")
End Try
**' code stop before this point**
Dim user = result.users.lists.Where(Function(x) x.GetType() Is GetType(TLUser)).Cast(Of TLUser)().FirstOrDefault(Function(x) x.phone Is normalizedNumber)
If user Is Nothing Then
Throw New System.Exception("Number was not found in Contacts List of user: " & NumberToSendMessage)
End If
Await client.SendTypingAsync(New TLInputPeerUser() With {.user_id = user.id})
Thread.Sleep(3000)
Await client.SendMessageAsync(New TLInputPeerUser() With {.user_id = user.id}, Msg)
End If
End If
End Function
SESSION.DAT is at app folder and updated every attempt
TKS
C:\Program Files (x86)\IIS Express\session.dat access is deny in web host how change address session.dat
I have this problem too.
+1 session not work need MakeAuth every time
same AUTH_KEY_UNREGISTERED problem for me!
changing from client.ConnectAsync(true); to client.ConnectAsync(false);
solved my AUTH_KEY_UNREGISTERED problem
@okarpov I have this problem exactly. there is something wrong with client.ConnectAsync(true);
@sochix can you please check this issue?
Hi I created and connected (ConnectAsync), sent the code and authed (MakeAuthAsync) this function successfully returned the TLUser object, also IsUserAuthorized returns true. At this time everything is ok and GetUserDialogsAsync is ok
Now if I close the program and start it again, despite IsUserAuthorized return true, but SendMessageAsync throws a AUTH_KEY_UNREGISTERED
The 'AUTH_KEY_UNREGISTERED' error is on :
var dialogs = (TLDialogs)await _client.GetUserDialogsAsync();
full code
var store = new FileSessionStore();
TelegramClient _client = new TelegramClient(11***9, "b****445dff9d19ff3631", store, "sessionName");
await _client.ConnectAsync();
if (!_client.IsUserAuthorized())
{
var hashKey = await _client.SendCodeRequestAsync("+********");
TLUser myuser = await _client.MakeAuthAsync("+********", hashKey, TelegramSendedCode);
}
var dialogs = (TLDialogs)await _client.GetUserDialogsAsync();
I already test:
client.ConnectAsync()
client.IsUserAuthorized()
both TRUE
please help me
o have the same problem like Re3ar
Is there any update on this?
Hi! If you already have file session.dat, this works fo me: string fullPathToDat = Directory.GetCurrentDirectory() + "\session"; var store = new FileSessionStore(); client = new TelegramClient(apiId, apiHash, store, fullPathToDat); await client.ConnectAsync(false);
Hi @sochix @marshallmick007 @ahmadalli @ra0o0f @Starli0n
Thanks for great work on TLSharp.
I am facing issue from last 10 days, I have tried all thing that require to solve by googling and reading all issue here too, but still facing same error. I am able to connect successfully, but
tgClient.IsUserAuthorized()
always return false.Also
var result = await tgClient.IsPhoneRegistered(TGAUserPhoneNumber)
return true for number that I registered. I have register number byawait tgClient.MakeAuth(phoneNumber, TGApiHash, TGAUserCode)
and its working fine.I have also make tgClient client in single instant and also try to add it in each function. I have also try to remove all
await
word from each code and try with it too. My full code is mentioned below:I have download latest TLSharp `from your github. I have tried to change the ip address too in session.cs.
`//private const string defaultConnectionAddress = "149.154.167.40";
private const string defaultConnectionAddress = "91.108.56.165";` //Currently working with it
Full code
String TGASession = "session"; Int32 TGApiID = 94206; String TGApiHash = "283739c32efb49f436074bda369b83b8";
var store = new FileSessionStore(); var tgClient = new TelegramClient(store, TGASession, TGApiID, TGApiHash); ` var connected = await tgClient.Connect(); //Return true, connected successfully
var autho = tgClient.IsUserAuthorized(); //Always return false
String TGAUserPhoneNumber="91xxxxxxxxxx"; //Indian phone number, also try from german system too var res = await tgClient.ImportContactByPhoneNumber(TGAUserPhoneNumber); //Error : 401 : AUTH_KEY_UNREGISTERED
I have also added the Stack-trace which mentioned below:d__17.MoveNext() in C:\Users\Aarav\Downloads\TLSharp-master\TLSharp-master\TLSharp.Core\TelegramClient.cs:line 209
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter
at TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, MTProtoRequest request) in C:\Users\Aarav\Downloads\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs:line 288 at TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, MTProtoRequest request) in C:\Users\Aarav\Downloads\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs:line 193 at TLSharp.Core.Network.MtProtoSender.<Receive>d__9.MoveNext() in C:\Users\Aarav\Downloads\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs:line 144 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at TLSharp.Core.TelegramClient.1.GetResult() at FbTelegramApp.Form1.<btnConfigTele_Click>d__27.MoveNext() in D:\Rupen\Freelancer\Facebook Get Post and post to telegram - 11269388\FbTelegramApp\FbTelegramApp\Form1.cs:line 836
I request to please help as soon as possible.
I will sure add bitcoin on your provided account once the error resolve.
Please try to update it as soon as possible.
Waiting for your reply,
Thanks, Rupendra