Open vasyugan opened 4 years ago
Caused by line https://github.com/nextcloud/twofactor_gateway/blob/c7a23e6eb77fa5a44465d2f870a8e418e687b1ce/lib/Service/Gateway/Telegram/Gateway.php#L86.
In any case, there exception is logged one line above. Check your nextcloud.log. Every time this error occurs there should be two new lines.
I don't know if this is what you are looking for?
{"reqId":"pfKdLo2fm8rkZWuVZCv2","level":0,"time":"2019-12-11T08:20:04+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"twofactor_gateway","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":"sending telegram message to +*******, message: ******* is your Nextcloud verification code.","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}
{"reqId":"pfKdLo2fm8rkZWuVZCv2","level":0,"time":"2019-12-11T08:20:04+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"twofactor_gateway","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":"telegram bot token: ******","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}
Or maybe this one, where it repeatedly says "chat not found"
{"reqId":"YkguFAJJFEP0cdhHVNKw","level":0,"time":"2019-12-11T08:25:23+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"twofactor_gateway","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":"sending telegram message to +49************, message: 282163 is your Nextcloud verification code.","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}
{"reqId":"YkguFAJJFEP0cdhHVNKw","level":0,"time":"2019-12-11T08:25:23+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"twofactor_gateway","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":"telegram bot token: ***************************************","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}
{"reqId":"YkguFAJJFEP0cdhHVNKw","level":0,"time":"2019-12-11T08:25:23+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"twofactor_gateway","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":"sending telegram message to +49************","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}
{"reqId":"YkguFAJJFEP0cdhHVNKw","level":3,"time":"2019-12-11T08:25:23+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"twofactor_gateway","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":{"Exception":"Telegram\\Bot\\Exceptions\\TelegramResponseException","Message":"Bad Request: chat not found","Code":400,"Trace":[{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramResponse.php","line":100,"function":"create","class":"Telegram\\Bot\\Exceptions\\TelegramResponseException","type":"::","args":[{"__class__":"Telegram\\Bot\\TelegramResponse"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramResponse.php","line":81,"function":"makeException","class":"Telegram\\Bot\\TelegramResponse","type":"->","args":[]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramResponse.php","line":51,"function":"decodeBody","class":"Telegram\\Bot\\TelegramResponse","type":"->","args":[]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramClient.php","line":130,"function":"__construct","class":"Telegram\\Bot\\TelegramResponse","type":"->","args":[{"__class__":"Telegram\\Bot\\TelegramRequest"},{"__class__":"GuzzleHttp\\Psr7\\Response"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramClient.php","line":82,"function":"getResponse","class":"Telegram\\Bot\\TelegramClient","type":"->","args":[{"__class__":"Telegram\\Bot\\TelegramRequest"},{"__class__":"GuzzleHttp\\Psr7\\Response"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Traits\/Http.php","line":304,"function":"sendRequest","class":"Telegram\\Bot\\TelegramClient","type":"->","args":[{"__class__":"Telegram\\Bot\\TelegramRequest"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Traits\/Http.php","line":197,"function":"sendRequest","class":"Telegram\\Bot\\Api","type":"->","args":["POST","sendMessage",{"form_params":{"chat_id":"+49************","text":"282163 is your Nextcloud verification code."}}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Methods\/Message.php","line":49,"function":"post","class":"Telegram\\Bot\\Api","type":"->","args":["sendMessage",{"form_params":{"chat_id":"+49************","text":"282163 is your Nextcloud verification code."}}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/lib\/Service\/Gateway\/Telegram\/Gateway.php","line":81,"function":"sendMessage","class":"Telegram\\Bot\\Api","type":"->","args":[{"chat_id":"+49************","text":"282163 is your Nextcloud verification code."}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/lib\/Service\/SetupService.php","line":92,"function":"send","class":"OCA\\TwoFactorGateway\\Service\\Gateway\\Telegram\\Gateway","type":"->","args":[{"__class__":"OC\\User\\User"},"+49************","282163 is your Nextcloud verification code."]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/lib\/Controller\/SettingsController.php","line":90,"function":"startSetup","class":"OCA\\TwoFactorGateway\\Service\\SetupService","type":"->","args":[{"__class__":"OC\\User\\User"},"telegram","+49************"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":170,"function":"startVerification","class":"OCA\\TwoFactorGateway\\Controller\\SettingsController","type":"->","args":["telegram","+49************"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\TwoFactorGateway\\Controller\\SettingsController","startVerification",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/************\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/************\/lib\/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start"]},{"file":"\/var\/www\/************\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Exceptions\/TelegramResponseException.php","Line":67,"Previous":{"Exception":"Telegram\\Bot\\Exceptions\\TelegramOtherException","Message":"Bad Request: chat not found","Code":400,"Trace":[{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramResponse.php","line":100,"function":"create","class":"Telegram\\Bot\\Exceptions\\TelegramResponseException","type":"::","args":[{"__class__":"Telegram\\Bot\\TelegramResponse"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramResponse.php","line":81,"function":"makeException","class":"Telegram\\Bot\\TelegramResponse","type":"->","args":[]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramResponse.php","line":51,"function":"decodeBody","class":"Telegram\\Bot\\TelegramResponse","type":"->","args":[]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramClient.php","line":130,"function":"__construct","class":"Telegram\\Bot\\TelegramResponse","type":"->","args":[{"__class__":"Telegram\\Bot\\TelegramRequest"},{"__class__":"GuzzleHttp\\Psr7\\Response"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/TelegramClient.php","line":82,"function":"getResponse","class":"Telegram\\Bot\\TelegramClient","type":"->","args":[{"__class__":"Telegram\\Bot\\TelegramRequest"},{"__class__":"GuzzleHttp\\Psr7\\Response"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Traits\/Http.php","line":304,"function":"sendRequest","class":"Telegram\\Bot\\TelegramClient","type":"->","args":[{"__class__":"Telegram\\Bot\\TelegramRequest"}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Traits\/Http.php","line":197,"function":"sendRequest","class":"Telegram\\Bot\\Api","type":"->","args":["POST","sendMessage",{"form_params":{"chat_id":"+49************","text":"282163 is your Nextcloud verification code."}}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Methods\/Message.php","line":49,"function":"post","class":"Telegram\\Bot\\Api","type":"->","args":["sendMessage",{"form_params":{"chat_id":"+49************","text":"282163 is your Nextcloud verification code."}}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/lib\/Service\/Gateway\/Telegram\/Gateway.php","line":81,"function":"sendMessage","class":"Telegram\\Bot\\Api","type":"->","args":[{"chat_id":"+49************","text":"282163 is your Nextcloud verification code."}]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/lib\/Service\/SetupService.php","line":92,"function":"send","class":"OCA\\TwoFactorGateway\\Service\\Gateway\\Telegram\\Gateway","type":"->","args":[{"__class__":"OC\\User\\User"},"+49************","282163 is your Nextcloud verification code."]},{"file":"\/var\/www\/************\/apps\/twofactor_gateway\/lib\/Controller\/SettingsController.php","line":90,"function":"startSetup","class":"OCA\\TwoFactorGateway\\Service\\SetupService","type":"->","args":[{"__class__":"OC\\User\\User"},"telegram","+49************"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":170,"function":"startVerification","class":"OCA\\TwoFactorGateway\\Controller\\SettingsController","type":"->","args":["telegram","+49************"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/************\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\TwoFactorGateway\\Controller\\SettingsController","startVerification",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/************\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/************\/lib\/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start"]},{"file":"\/var\/www\/************\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/************\/apps\/twofactor_gateway\/vendor\/irazasyed\/telegram-bot-sdk\/src\/Exceptions\/TelegramResponseException.php","Line":67},"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}
Yes, that one.
Did you start a conversation with the bot?
Oh. and you're not supposed to enter your phone number for Telegram but the chat ID.
Oh. and you're not supposed to enter your phone number for Telegram but the chat ID.
Then the interface should be fixed. It says: "Enter your identification (e.g. phone number to start the verification):"
I guess a direct link to the id bot would be helpful. I guess the instructions could be clearer. It should instruct the user to talk to @my_id_bot (because you get many his when you look for "id bot" in Telegram) and then enter the obtained ID into the box. Also, is it possible to display the name of the Nextcloud telegram bot? I guess is should be obtainable, after all, Nextcloud does talk to Telegram, once it has the token.
There was an attempt to improve this at https://github.com/nextcloud/twofactor_gateway/pull/133.
:+1: on making it a link
The "Enter your …" is a generic text shown for every gateway type (sms, signal, telegram). Maybe we should remove the "(e.g. …)" part then it's more fitting for every gateway.
Just ran into this as I forgot to update the API key after resetting it.
Would be great to give a more useful error message, as it took a while for me to realise what was wrong.
I have registered a telegram bot as described in the instructions and configured it. Now, when I try to go through the verification process in my user account, I understand one first has to input one's phone number as it is known to Telegram:
+[country code][phone number without leading 0]
When I do that, the app says: "Could not verify your code. Please try again."
The log says:
{"reqId":"YkguFAJJFEP0cdhHVNKw","level":3,"time":"2019-12-11T08:25:23+00:00","remoteAddr":"2003:d3:c733:5400::c0d","user":"jr","app":"index","method":"POST","url":"\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start","message":{"Exception":"Exception","Message":"Wrong parameters for OCA\\TwoFactorGateway\\Exception\\SmsTransmissionException([string $message [, long $code [, Throwable $previous = NULL]]])","Code":0,"Trace":[{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\TwoFactorGateway\\Controller\\SettingsController","startVerification",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/Http\/Dispatcher.php","Line":109,"Previous":{"Exception":"Error","Message":"Wrong parameters for OCA\\TwoFactorGateway\\Exception\\SmsTransmissionException([string $message [, long $code [, Throwable $previous = NULL]]])","Code":0,"Trace":[{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/apps\/twofactor_gateway\/lib\/Service\/Gateway\/Telegram\/Gateway.php","line":86,"function":"__construct","class":"Exception","type":"->","args":[{"__class__":"Telegram\\Bot\\Exceptions\\TelegramResponseException"}]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/apps\/twofactor_gateway\/lib\/Service\/SetupService.php","line":92,"function":"send","class":"OCA\\TwoFactorGateway\\Service\\Gateway\\Telegram\\Gateway","type":"->","args":[{"__class__":"OC\\User\\User"},"+4915792331634","282163 is your Nextcloud verification code."]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/apps\/twofactor_gateway\/lib\/Controller\/SettingsController.php","line":90,"function":"startSetup","class":"OCA\\TwoFactorGateway\\Service\\SetupService","type":"->","args":[{"__class__":"OC\\User\\User"},"telegram","+4915792331634"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":170,"function":"startVerification","class":"OCA\\TwoFactorGateway\\Controller\\SettingsController","type":"->","args":["telegram","+4915792331634"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\TwoFactorGateway\\Controller\\SettingsController"},"startVerification"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\TwoFactorGateway\\Controller\\SettingsController","startVerification",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"gateway":"telegram","_route":"twofactor_gateway.settings.startVerification"}]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/lib\/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/twofactor_gateway\/settings\/telegram\/verification\/start"]},{"file":"\/var\/www\/htdocs\/cloud.xxx.xxx\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/htdocs\/cloud.xxx.xxx\/apps\/twofactor_gateway\/lib\/Service\/Gateway\/Telegram\/Gateway.php","Line":86},"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:71.0) Gecko\/20100101 Firefox\/71.0","version":"17.0.1.1"}