[PR #8377] [CLOSED] feat: add Telegram social provider (OIDC) #7932

Closed
opened 2026-03-13 13:53:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8377
Author: @whereissam
Created: 3/4/2026
Status: ❌ Closed

Base: canary ← Head: feat/telegram-social-provider


📝 Commits (2)

  • d2091bb feat: add Telegram social provider (OIDC)
  • baa958d fix: use jose decodeJwt for Telegram id_token to fix UTF-8 and align with other providers

📊 Changes

3 files changed (+271 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/social.test.ts (+168 -0)
📝 packages/core/src/social-providers/index.ts (+3 -0)
➕ packages/core/src/social-providers/telegram.ts (+100 -0)

📄 Description

Summary

  • Add native Telegram Login as a social provider via their OAuth 2.0 / OIDC endpoint
  • Uses PKCE + basic auth, decodes JWT id_token for user profile (Telegram has no userinfo
    endpoint)
  • Maps sub → id, name/preferred_username → name, phone_number → email
    (@telegram.local), picture → image

Files changed

  • packages/core/src/social-providers/telegram.ts — new provider implementation
  • packages/core/src/social-providers/index.ts — register and export
  • packages/better-auth/src/social.test.ts — 3 tests (config, OAuth flow, full user creation)

Test plan

  • Unit tests pass (pnpm test in packages/better-auth)
  • Tested end-to-end with real Telegram OAuth via @BotFather bot
  • Build, lint (Biome), and typecheck all pass

References

Open the PR at: https://github.com/better-auth/better-auth/compare/canary...whereissam:better-
auth:feat/telegram-social-provider

Base branch: canary


Summary by cubic

Adds Telegram as a social login provider using OAuth 2.0/OIDC. Uses PKCE and decodes the id_token with jose to build user profiles (no userinfo endpoint).

  • New Features

    • New Telegram provider with PKCE and basic auth; auth URL oauth.telegram.org/auth, token URL oauth.telegram.org/token; default scopes: openid, profile, phone.
    • Decodes id_token with jose.decodeJwt and maps claims: sub → user id, name/preferred_username → name, phone_number → email (+number@telegram.local), picture → image; emailVerified = true.
    • Provider registered and exported in the core index.
    • Tests added for config, OAuth flow (PKCE), and end-to-end user creation.
  • Migration

    • Add telegram to your socialProviders with clientId and clientSecret.
    • Set the Telegram callback route (e.g., /callback/telegram) in your app and bot settings.
    • Optionally override mapProfileToUser to customize fields like email; no schema changes needed.

Written for commit baa958dbbb. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8377 **Author:** [@whereissam](https://github.com/whereissam) **Created:** 3/4/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/telegram-social-provider` --- ### 📝 Commits (2) - [`d2091bb`](https://github.com/better-auth/better-auth/commit/d2091bb32c21c858a3216326f2506331c29fe087) feat: add Telegram social provider (OIDC) - [`baa958d`](https://github.com/better-auth/better-auth/commit/baa958dbbb0b8e13d6d76963a5f19d9265bf82df) fix: use jose decodeJwt for Telegram id_token to fix UTF-8 and align with other providers ### 📊 Changes **3 files changed** (+271 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/social.test.ts` (+168 -0) 📝 `packages/core/src/social-providers/index.ts` (+3 -0) ➕ `packages/core/src/social-providers/telegram.ts` (+100 -0) </details> ### 📄 Description # Summary - Add native Telegram Login as a social provider via their OAuth 2.0 / OIDC endpoint - Uses PKCE + basic auth, decodes JWT `id_token` for user profile (Telegram has no userinfo endpoint) - Maps `sub` → id, `name`/`preferred_username` → name, `phone_number` → email (`@telegram.local`), `picture` → image ## Files changed - `packages/core/src/social-providers/telegram.ts` — new provider implementation - `packages/core/src/social-providers/index.ts` — register and export - `packages/better-auth/src/social.test.ts` — 3 tests (config, OAuth flow, full user creation) ## Test plan - [x] Unit tests pass (`pnpm test` in `packages/better-auth`) - [x] Tested end-to-end with real Telegram OAuth via @BotFather bot - [x] Build, lint (Biome), and typecheck all pass ## References - [Telegram Login Widget docs](https://core.telegram.org/widgets/login) - [Telegram OAuth/OIDC](https://telegram.org/blog/telegram-login-widget) Open the PR at: https://github.com/better-auth/better-auth/compare/canary...whereissam:better- auth:feat/telegram-social-provider Base branch: canary <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds Telegram as a social login provider using OAuth 2.0/OIDC. Uses PKCE and decodes the id_token with jose to build user profiles (no userinfo endpoint). - **New Features** - New Telegram provider with PKCE and basic auth; auth URL oauth.telegram.org/auth, token URL oauth.telegram.org/token; default scopes: openid, profile, phone. - Decodes id_token with jose.decodeJwt and maps claims: sub → user id, name/preferred_username → name, phone_number → email (+number@telegram.local), picture → image; emailVerified = true. - Provider registered and exported in the core index. - Tests added for config, OAuth flow (PKCE), and end-to-end user creation. - **Migration** - Add telegram to your socialProviders with clientId and clientSecret. - Set the Telegram callback route (e.g., /callback/telegram) in your app and bot settings. - Optionally override mapProfileToUser to customize fields like email; no schema changes needed. <sup>Written for commit baa958dbbb0b8e13d6d76963a5f19d9265bf82df. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:53:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7932