BotAuth is a package that allows you to log in using a Vkontakte, FaceBook, Telegram bot.
The main task of BotAuth is to make it easier for visitors to access Web sites / PWA through social networks. ')
While soc. networks do not implement the feedback of native mobile applications with the web site, developers have to send the user to the browser, where they need to enter their login and password again.
In the community settings, open the section “Settings” - “Working with API”
Create an access key, select the item “Allow the application access to community messages”, write down the key, you need to specify it in .env BOTAUTH_VKONTAKTE_API_TOKEN
On the same page, select Callback API, select API Version 5.95 , enter the address of your site in the Address field, the default example
https://DOMAIN/botauth/callback/vkontakte
Below indicate the line that the server should return to .env BOTAUTH_VKONTAKTE_API_CONFIRM
In the field “Secret key” invent any secret key, specify in .env BOTAUTH_VKONTAKTE_API_SECRET
After filling in all the keys in .env, click "Verify"
On the same page, open the “Event Types” tab, select “Inbox Messages”
Open the settings of the community, the "Messages" item, turn on the "community messages"
Open the community settings, the "Messages" item - "Settings for the bot", enable the "Bots features"
The bot is ready to go.
An example of a direct link to the dialogue with the bot
https://vk.me/zetcode
Telegram
Create your bot via @BotFather
Remember the key, specify in .env BOTAUTH_TELEGRAM_API_TOKEN
In the settings of the application, select “Basic”, copy the “Secret of the application” in .env BOTAUTH_FACEBOOK_API_SECRET
In the settings of the application, you need to add the product "Messenger"
In the settings of the product “Messenger” create an access token, specify it in .env BOTAUTH_FACEBOOK_API_TOKEN
In the settings of the product "Messenger" create a web hook, in the callback URL specify
https://DOMAIN/botauth/callback/facebook
replace DOMAIN with your domain
In the field “Confirm marker” enter any text, save it in .env BOTAUTH_FACEBOOK_API_CONFIRM
In the "Subscription Fields" options, select "messages"
Click "Confirm"
After confirming the server in the settings of the web hooks, select the page, click "Subscribe", select the page
In the “Messenger App Test” window, next to “pages_messaging”, click “Add to Application”
The bot is ready to work, but is available only to administrators.
After confirmation of the application, it will be available to all visitors. Submit the application for moderation.
An example of a direct link to the dialogue with the bot
https://m.me/zetridercode
Important:
The site should work on https
Facebook bot returns a PSID that does not match the public user ID.
By default, the bot controller works with the model \ App \ User. If you have another case, simply create your controller and model based on examples from the repository. Model , Controller
How to add your provider:
Create your class that inherits the abstract class.