title: Telegram authorization without default button
body: <p>The only documented way to use Telegram 3-rd party authorization is to use their script that is being provided at <a href="https://core.telegram.org/widgets/login" rel="noreferrer">https://core.telegram.org/widgets/login</a></p>
  
  <p>This script (as I digged) works in pretty strange way</p>
  
  <ol>
  <li>It renders "Log in with Telegram" button inside the <code>iframe</code> with another extra <code>script</code> that loads some Telegram entities to work with (like <code>TWidgetLogin</code>, <code>TSticker</code> <strong>(?)</strong>, <code>TVideo</code> <strong>(??)</strong>, <code>TAudio</code> <strong>(???)</strong> and some others).</li>
  <li>By clicking on button, this <code>iframe</code> opens new window that is performing authorization.</li>
  <li>After authorization is being completed, this window is being closed, and since it's done, the <code>iframe</code> checks the authorization again. If it's done in right way, the <code>iframe</code> retrieves all shared user info and dependent on type of authorization end calls <code>data-onauth</code> or sends request to <code>data-auth-url</code>.</li>
  </ol>
  
  <p>This behaviour is really unusable for me, because we are also using Google , Github and Facebook OAuths nearby, and all of them are providing the normal usable API to open authorization windows manually and do redirects to specified url.</p>
  
  <p>I mean, that's how our, for example, Google authorization works:</p>
  
  <ol>
  <li>User clicks on button that is created <strong>on our own</strong>, customized to match our application style.</li>
  <li>On click, our application creates new window with url <code>https://hostname/some/path/to/auth?and_some_params=here</code></li>
  <li>Our server catches this and redirects to Google OAuth consent screen.</li>
  <li>After Google authorization is being completed, it redirects user to another <code>/some/path/to/completed_authorization</code></li>
  <li>Server retrieves all necessary information, and redirects window to <code>/some/path/to/success_authorization</code> that has script with <code>window.postMessage</code> to parent window with authorization info.</li>
  <li>Parent window (application window) catches this message, closes window and fills storage with given user data.</li>
  </ol>
  
  <p>And thats done. Since opened window is being opened by application, it can be controlled and closed when it's not in use (e.g. when another auth window is being opened, or when the application tab is being closed).</p>
  
  <p>What is unsuitable in telegram "Log in with telegram" button is:</p>
  
  <ol>
  <li>No possibility to stylize button to match application style</li>
  <li>No possibility to change content of the button (in our case it is necessary, because our application is multilanguage).</li>
  <li>No possibility to control opened window (it is being opened even if the main window is closed)</li>
  </ol>
  
  <hr>
  
  <p>For now I can open a window with Telegram OAuth screen using</p>
  
  <pre><code>// some code above
  this.popup = window.open("https://oauth.telegram.org/auth?bot_id=&lt;my_bot_id&gt;&amp;origin=http%3A%2F%2F&lt;mydevorigin&gt;&amp;request_access=write, "authWindow", &lt;some window params&gt;)
  // some code below
  </code></pre>
  
  <p>But since authorization is being completed, I cannot set anything to let server know that it should retrieve user data and redirect to my page with <code>window.postMessage</code></p>
  
  <p>Is there any way to achieve Telegram authorization without their "Login with Telegram" button? Any help is highly appreciated.</p>