php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

"connection setup failed" when trying gmail oauth connection using token

Open birizara opened this issue 3 years ago • 1 comments

Hi,

When we try to connect to gmail account with a token that we have got previously after a user authorize our app, we have this error What are we doing wrong?

Is this library supporting Google oauth?

Fatal error: Uncaught exception 'Webklex\PHPIMAP\Exceptions\AuthFailedException' in /home/admin/web/inmotek.com/public_html/libraries/php_imap/vendor/webklex/php-imap/src/Client.php:385 [106] => Stack trace: [107] => #0 /home/admin/web/inmotek.com/public_html/libraries/php_imap/vendor/webklex/php-imap/src/Client.php(371): Webklex\PHPIMAP\Client->authenticate() [108] => #1 /home/admin/web/inmotek.com/public_html/crons/email/retriever.php(95): Webklex\PHPIMAP\Client->connect() [109] => #2 {main} [110] => [111] => Next exception 'Webklex\PHPIMAP\Exceptions\ConnectionFailedException' with message 'connection setup failed' in /home/admin/web/XXXXX/public_html/libraries/php_imap/vendor/webklex/php-imap/src/Client.php:391 [112] => Stack trace: [113] => #0 /home/admin/web/XXXXX/public_html/libraries/php_imap/vendor/webklex/php-imap/src/Client.php(371): Webklex\PHPIMAP\Client->authenticate() [114] => #1 /home/admin/web/XXXXXX/public_html/crons/email/retriever.php(95): Webklex\PHPIMAP\Client->connect() [115] => #2 {main} [116] => thrown in /home/admin/web/inmotek.com/public_html/libraries/php_imap/vendor/webklex/php-imap/src/Client.php on line 391

Webklex\PHPIMAP\Client Object [26] => ( [27] => [connection] => [28] => [host] => imap.gmail.com [29] => [port] => 993 [30] => [protocol] => imap [31] => [encryption] => ssl [32] => [validate_cert] => 1 [33] => [proxy:protected] => Array [34] => ( [35] => [socket] => [36] => [request_fulluri] => [37] => [username] => [38] => [password] => [39] => ) [40] => [41] => [timeout] => 30 [42] => [username] => [email protected] [43] => [password] => DATA_ACCESS_TOKEN_OBTAINED_FROM_GOOGLE [44] => [extensions] => Array [45] => ( [46] => ) [47] => [48] => [authentication] => oauth [49] => [active_folder:protected] => [50] => [default_message_mask:protected] => Webklex\PHPIMAP\Support\Masks\MessageMask [51] => [default_attachment_mask:protected] => Webklex\PHPIMAP\Support\Masks\AttachmentMask [52] => [default_account_config:protected] => Array [53] => ( [54] => [host] => localhost [55] => [port] => 993 [56] => [protocol] => imap [57] => [encryption] => ssl [58] => [validate_cert] => 1 [59] => [username] => [60] => [password] => [61] => [authentication] => [62] => [extensions] => Array [63] => ( [64] => ) [65] => [66] => [proxy] => Array [67] => ( [68] => [socket] => [69] => [request_fulluri] => [70] => [username] => [71] => [password] => [72] => ) [73] => [74] => [timeout] => 30 [75] => ) [76] => [77] => [events:protected] => Array [78] => ( [79] => [message] => Array [80] => ( [81] => [new] => Webklex\PHPIMAP\Events\MessageNewEvent [82] => [moved] => Webklex\PHPIMAP\Events\MessageMovedEvent [83] => [copied] => Webklex\PHPIMAP\Events\MessageCopiedEvent [84] => [deleted] => Webklex\PHPIMAP\Events\MessageDeletedEvent [85] => [restored] => Webklex\PHPIMAP\Events\MessageRestoredEvent [86] => ) [87] => [88] => [folder] => Array [89] => ( [90] => [new] => Webklex\PHPIMAP\Events\FolderNewEvent [91] => [moved] => Webklex\PHPIMAP\Events\FolderMovedEvent [92] => [deleted] => Webklex\PHPIMAP\Events\FolderDeletedEvent [93] => ) [94] => [95] => [flag] => Array [96] => ( [97] => [new] => Webklex\PHPIMAP\Events\FlagNewEvent [98] => [deleted] => Webklex\PHPIMAP\Events\FlagDeletedEvent [99] => ) [100] => [101] => ) [102] => [103] => )

birizara avatar May 11 '22 11:05 birizara

Hi @birizara , thanks for your report. It looks like the account authentication failed. Regarding OAuth, checkout these examples: https://www.php-imap.com/examples/oauth

If you are still experiencing problems, try to enable the debug mode inside your config file: https://github.com/Webklex/php-imap/blob/master/src/config/imap.php#L152

Best regards,

Webklex avatar Aug 09 '22 06:08 Webklex