Skip to content

API 4.3 - Seamless Telegram Login #957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 15, 2019

Conversation

noplanman
Copy link
Member

Closes #955

@noplanman noplanman self-assigned this Jun 2, 2019
@noplanman noplanman requested a review from a team June 10, 2019 00:31
@noplanman
Copy link
Member Author

This should be good to go, if somebody could add their eyes to check, that would be sweet 💪

@php-telegram-bot/developers

@noplanman noplanman merged commit ac4c506 into php-telegram-bot:develop Jun 15, 2019
@noplanman noplanman deleted the 955-bot_api_4.3 branch June 26, 2019 14:43
@rick20
Copy link

rick20 commented Apr 3, 2020

@noplanman is there any example how to use the seamless telegram login?
Spent the entire day digging for clue just to find out how to use this login_url but couldnt get anything.
https://core.telegram.org/api/url-authorization didnt help at all
thank you, i really appreciate your work

@ossiach
Copy link

ossiach commented Apr 3, 2020

@noplanman is there any example how to use the seamless telegram login?
Spent the entire day digging for clue just to find out how to use this login_url but couldnt get anything.

What exactly is your problem?

If you don't know how to send the login button to a user/group then this code example might be useful:

$login_object = new LoginUrl([
	'url' => 'https://mydomain.com/check_authorization.php',
	'request_write_access' => true,
]);

$login_keyboard = new InlineKeyboard([
	['login_url' => $login_object, 'text' => 'Click this button to login'],
]);


$data = [
	'chat_id' => $receiverChatId,
	'reply_markup' => $login_keyboard,
	'text'   => 'This is a basic text message with a login button beneath',
];
Request::sendMessage($data);

Don't forget that you have to link the domain first to your bot or otherwise the login button probably won't work as intended. To link a specific domain to your bot send the /setdomain Command to the @botfather.

The message received by this code example should have a login button beneath it. If the user clicks on it, Telegram will open the specified URL in a browser. The PHP File behind this URL now has to verify the authenticity of the received information. If everything works fine, the user will be logged in on your website.

If you are struggling with the authorization part on the web server, I would recommend the official guide for the Telegram Login Widget, because the authorization for the Login Widget works exactly the same way as the Seamless Telegram Login. In fact, if you have already integrated the Telegram Login Widget on your website, you can link the Seamless Login URL to the authorization file from your Login Widget and it will work without any further configuration needed.

If you don't know how implement the authorization file itself, I can recommend this code example. I am using the check_authorization.php code myself for my own bot.

I hope these tips can help you (and everyone else stumbling across this topic).

@rick20
Copy link

rick20 commented Apr 4, 2020

@ossiach @noplanman apologize for double post my question.

As my comment in #1065 what I’ve got so far:

  • write exactly the same code just like what you said
  • got the inline button showing up below my bot message
  • got the login confirmation dialog showing up when I click the inline button

However, when my page was opened, I see there’s no query string appended to my auth url. It’s just like a normal page, the exact same url I set in LoginUrl.

The documentation here talk about messages.acceptUrlAuth and urlAuthResultAccepted but there’s no guide on how to use it.
Are those parameters something I should care to know?

@noplanman
Copy link
Member Author

Will move this conversation to your initial issue, so others can find the solution more easily...

#1065

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

Successfully merging this pull request may close these issues.

3 participants