Usage

Prerequisites

Magic SDK offers two OAuth extensions: v1 and v2. For web applications, it is recommended to use v2, while v1 should be used for mobile applications.

Telegram Setup

After installing the OAuth extension, you can now enable Telegram Login for your Magic app:
  1. Follow Telegram instructions to create a bot
  2. Provide Bot name and Bot Token in your Magic developer dashboard
  3. Optionally enable Seamless login with Mini App
  4. Copy the Redirect URI field from your Magic Dashboard and set it as your bot domain using command /setdomain in @BotFather
If you have CSP enforcement, allow the following script-src:

Implementation

JavaScript
await magic.oauth2.loginWithPopup({
  provider: 'telegram'
});
The result interface:
interface OAuthRedirectResult {
  magic: {
    idToken: string;
    userMetadata: MagicUserMetadata;
  },
  oauth: {
    provider: string;
    scope: string[];
    accessToken: string;
    userHandle: string;
    userInfo: ...;
  }
};
Keep your token secure and store it safely, it can be used by anyone to control your bot

Resources