Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Error API_ID_INVALID, but the code is correct #442

Closed
claytonbnu opened this issue Apr 6, 2017 · 23 comments
Closed

Error API_ID_INVALID, but the code is correct #442

claytonbnu opened this issue Apr 6, 2017 · 23 comments

Comments

@claytonbnu
Copy link

This is the configuration of https://my.telegram.org/apps.

telegram

This is the code, the appId and apiHash is same of configurantion in the https://my.telegram.org/apps:

using System;
using System.Threading.Tasks;
using TLSharp.Core;

namespace IntegracaoTelegram
{
    class Program
    {        
        const string phoneNumber = "+554799111170";
        const int apiId = 100283;
        const string apiHash = "e1bcXXXXXXXXXXXXXXXXXX908a";

        static void Main(string[] args)
        {
            Service bot = new Service(apiId, apiHash);
            Authenticate(bot).Wait();

            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
        }
           
       static async Task Authenticate(Service bot)
         {
             await bot.Connect();
             await bot.Authenticate(phoneNumber);
         }
    }

    public sealed class Service
    {
        private TelegramClient client;
        private ISessionStore store;
        public Service(int apiId, string apiHash)
        {
            store = new FileSessionStore();
            this.client = new TelegramClient(apiId, apiHash, store);
        }

        public async Task Connect()
        {
            await this.client.ConnectAsync();
        }

        public async Task Authenticate(String phoneNumber)
        {
            var hash = await client.SendCodeRequestAsync(phoneNumber);                     

            Console.WriteLine("Inform the received code from Telegram: ");
            var code = Console.ReadLine(); 

            var user = await client.MakeAuthAsync(phoneNumber, hash, code);

            Console.WriteLine("The UserID is: {0}",user.id);
        }
    }
}

And this is the Error!
error

What did I do wrong?

@samuelg78
Copy link

I also experienced the same issue.

@samuelg78
Copy link

Seems like all new numbers will have this errors due to recently updates of Telegram.

@knocte
Copy link
Collaborator

knocte commented Apr 7, 2017

Please post the exception, not screenshots. The exception is the text you get when you do ex.ToString()

@samuelg78
Copy link

The exception is "API_ID_INVALID"

@knocte
Copy link
Collaborator

knocte commented Apr 7, 2017

That's not an exception, that's an error code.

@nazmotka
Copy link

nazmotka commented Apr 7, 2017

Experiencing the same problem for a newly registered dev account. I haven't observed this issue using another account, generated for about two weeks ago. The only noticeable difference between these accounts is that API_ID for the new account contains 6 digits, but previous one - 5.

@nazmotka
Copy link

nazmotka commented Apr 7, 2017

That's not an exception, that's an error code.

If you are expecting a stack trace, please see below:

at TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
at TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
at TLSharp.Core.Network.MtProtoSender.d__9.MoveNext()
--- 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.TaskAwaiter1.GetResult() at TLSharp.Core.TelegramClient.<SendCodeRequestAsync>d__13.MoveNext() --- 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.TaskAwaiter1.GetResult()
at {my_code}

@samuelg78
Copy link

image

@knocte
Copy link
Collaborator

knocte commented Apr 7, 2017

To be strict, a stacktrace is only one part of the exception. ex.ToString() however includes more things, such as: exception's message, innerException.tostring() (recursively until finding a null innerException), and the exception's stacktrace.

@nazmotka
Copy link

nazmotka commented Apr 7, 2017

ex.ToString() result

System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: API_ID_INVALID
at TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
at TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
at TLSharp.Core.Network.MtProtoSender.d__9.MoveNext()
--- 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.TaskAwaiter1.GetResult() at TLSharp.Core.TelegramClient.<SendCodeRequestAsync>d__13.MoveNext() --- 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.TaskAwaiter1.GetResult()
at TelegramLibrary.TelegramClientWrapper.d__5.MoveNext() in C:\Devel...:line 48
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at ... my code ... :line 338
---> (Inner Exception #0) System.InvalidOperationException: API_ID_INVALID
at TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
at TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
at TLSharp.Core.Network.MtProtoSender.d__9.MoveNext()
--- 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.TaskAwaiter1.GetResult() at TLSharp.Core.TelegramClient.<SendCodeRequestAsync>d__13.MoveNext() --- 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.TaskAwaiter1.GetResult()
at TelegramLibrary.TelegramClientWrapper.d__5.MoveNext() in C:\Devel...line 48<---

@samuelg78
Copy link

Hi, able to resolve the issue?

@astuteficus
Copy link

astuteficus commented Apr 10, 2017

I have the same with freshly registered ApiId. Does anybody have it working?

@astuteficus
Copy link

astuteficus commented Apr 10, 2017

Works with another ApiId (obtained a long time ago). So it's Telegram's issue

@samuelg78
Copy link

How to report to telegram? The support is not responding.

@samuelg78
Copy link

Hi anyone got reply from telegram support?

@astuteficus
Copy link

I wrote them too several days ago. No answer.

@samuelg78
Copy link

There's a serious issue with the support.

@HemmatSharp
Copy link

I have same problem with api_id and get no response from telegram support.

@jak65
Copy link

jak65 commented Apr 12, 2017

I have same problem too

@nazmotka
Copy link

More than a week have passed since I reported to support (and also to the official support community), but I still haven't received any response.

@StrangePers
Copy link

I wrote them 5 times for the last 3 months with different issues and from several accounts. They never answered.

@samuelg78
Copy link

They had just replied that they fixed the problem.

@nazmotka
Copy link

Yes, I confirm the issue is fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants