1.1.2 • Published 5 years ago
react-telegram-login v1.1.2
React Telegram Login
A Telegram OAuth Sign-in / Log-in Component for React

Install
npm install react-telegram-loginor
yarn add react-telegram-loginHow to use
import React from 'react';
import ReactDOM from 'react-dom';
import TelegramLoginButton from 'react-telegram-login';
const handleTelegramResponse = response => {
console.log(response);
};
ReactDOM.render(
<TelegramLoginButton dataOnauth={handleTelegramResponse} botName="OdauBot" />,
document.getElementById('telegramButton')
);Notes:
- Login widget will not work on
localhostorlocal-ip-address. Use should create and register your bot domain with BotFather to get that work. You can create your custom domain. For example:yourdomain.localby add new record point to your local ip by edithostsfile. - It's only run on port 80. When you use
create-react-app. You must runsudo yarn PORT=80 start, or on Windows CMD (not powershell),set PORT=80 && yarn start
Parameters
Telegram Scopes List: https://core.telegram.org/widgets/login
dataOnauth callback
dataOnauth callback returns a TelegramUser object which provides access to all of the TelegramUser methods listed here: https://core.telegram.org/widgets/login.
dataAuthUrl redirection url
dataAuthUrl is a string which corresponds to the url where the user is redirected after a successful authorization. You should either use dataAuthUrl or dataOnauth, not both of them
Receiving authorization data
After a successful authorization, the widget can return data in two ways:
- by redirecting the user to the URL specified in the data-auth-url attribute with the following parameters:
id,first_name,last_name,username,photo_url,auth_date,hashandlang; - by calling the callback function data-onauth with the JSON-object containing
id,first_name,last_name,username,photo_url,auth_date,hashandlangfields.
<TelegramLoginButton dataOnauth={this.handleUserInfo} botName="OdauBot" />Dev Server
npm run startYou can set IP and PORT in webpack.config.js
Run Tests
npm run test:watchProduction Bundle
npm run bundle1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2-beta-6
8 years ago
1.0.2-beta-4
8 years ago
1.0.2-beta-3
8 years ago
1.0.2-beta-2
8 years ago
1.0.2-beta-1
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago