Skip to content
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

[Feature Request] Google OAuth Support #411

Open
freescout-helpdesk opened this issue Dec 24, 2019 · 14 comments
Open

[Feature Request] Google OAuth Support #411

freescout-helpdesk opened this issue Dec 24, 2019 · 14 comments
Labels
enhancement This will enhance this library. need help Your support is required to solve this issue. needs investigation This will be tested / debugged or checked out.

Comments

@freescout-helpdesk
Copy link

Is Google OAuth authentication supported in this library? google/gmail-oauth2-tools#18

@freescout-helpdesk freescout-helpdesk added the needs investigation This will be tested / debugged or checked out. label Dec 24, 2019
@Sebbo94BY Sebbo94BY added enhancement This will enhance this library. need help Your support is required to solve this issue. labels Dec 25, 2019
@Sebbo94BY
Copy link
Collaborator

Very good point! Right now, it's not supported yet, unfortunately.

I've added a few functions in order to support OAuth, but I couldn't test it yet. It should later work like this:

// Create PhpImap\Mailbox instance for all further actions
$mailbox = new PhpImap\Mailbox(
	'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
	'some@gmail.com', // Username for the before configured mailbox
	'*********', // Password for the before configured username
	__DIR__, // Directory, where attachments will be saved (optional)
	'UTF-8' // Server encoding (optional)
);

try {
    $mailbox->setOAuthToken('TheOAuthAccessToken');
} catch (Exception $ex) {
    die('Authentication using OAuth failed! Error: '.$ex->getMessage());
}

try {
	$mailsIds = $mailbox->searchMailbox('ALL');
} catch(PhpImap\Exceptions\ConnectionException $ex) {
	die('IMAP connection failed: '.$ex);
}

if(!$mailsIds) {
	die('Mailbox is empty');
}

$mail = $mailbox->getMail($mailsIds[0]);

You can give it a try by using the develop branch: git checkout develop

I'll try to implement a working and tested solution, but this will earliest happen next year due to the current holidays. Any help would be appreciated.


Useful references:

@bapcltd-marv
Copy link
Contributor

running automated testing for this would require changes mentioned in #432 (comment), or finding an IMAP-enabled mail provider that supports automated account creation w/ oauth imap so the account can be created & deleted on each travis build.

@hrst
Copy link

hrst commented Jul 26, 2021

Please forgive me asking, but are there any updates on this? It would be so helpful to have OAuth support for e.g. GMail/Google Workspace, and Microsoft Office 365 mail accounts.

I'm willing to help / do the implementation, what is the current status?

@Sebbo94BY
Copy link
Collaborator

There are no updates yet.

I've tried to work and implement it some time ago, so the current progress is available in the respective branch: 411-OAuth-Support

Feel free to submit your own pull request or add commits to the existing one.

@francescobianco
Copy link

francescobianco commented May 24, 2022

Hi! @freescout-helpdesk @Sebi94nbg @hrst @bapcltd-marv @rmontagud

The strategy to overcome the problem is replacing all the imap_* functions with the equivalent imap2_*

  • imap_open(...) become imap2_open(...)
  • imap_getmailboxes(...) become imap2_getmailboxes(...)

etc...

The idea behind the imap2 library is to replace the core php imap extension with a new one written in PHP.
Why? We have problem with the UW-IMAP https://github.com/uw-imap/imap it seem outdate from 2019. There are many security concerns about it

I'm waiting from your feedback! I hope that imap2 is a good replacement for imap

cc @millnet-maho

@hrst
Copy link

hrst commented Jul 14, 2022

Just a heads-up to everyone: Microsoft will disable Basic Auth on Oct 1st, 2022. In contrast to Google, "App Passwords" will not be possible/allowed, only OAuth2.

Status for PHP imap_* extension (page not updated since 2020 as of writing this): https://wiki.php.net/todo/ext/imap/xoauth2

@bhanu2217
Copy link

When we plan to add support for oAuth to this package?

@kurznet
Copy link

kurznet commented Oct 7, 2022

is there any plan to support oAuth? because Microsoft will disable Basic Auth in Januar 2023
look here: https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-deprecation-in-exchange-online-september/ba-p/3609437

@nettunodev
Copy link

Hello, as a workaround is there maybe the possibility to login using another library, like https://www.php-imap.com/ that does support oauth and then pass the object in some way to keep working with this php-imap library? We built a whole app using this library and we would do anything to avoid rewriting everything... Thanks!

@Sebbo94BY
Copy link
Collaborator

Hello everyone,
back in 2019 I already worked on the OAuth support, but I had no chance to test it.

These changes are still on the 411-OAuth-Support branch, so if somebody could test it and provide feedback, it would be great.

Pull requests by other people are also welcome.

Since christmas time is coming soon and I'm also currently working on some other projects, I can't gurantee, that I can finish this implementation until end of December 2022. However, I'll try my best to get it done.

Sebbo94BY pushed a commit that referenced this issue Dec 14, 2022
@VortexCallouts
Copy link

has anyone be able to get this to work correctly I am trying to update for Outlook update.

@kurznet
Copy link

kurznet commented Jan 10, 2023

hi everyone,
any news about OAuth-Support? we got today the "Exchange Online Basic Auth Deprecation – 7 Day Notice" in Office 365 Center

Approximately 7 days from today, we’re going to permanently disable basic authentication for the
following Exchange Online protocols: MAPI, RPC, Offline Address Book, Exchange Web Services,
POP, IMAP, Exchange ActiveSync and Remote PowerShell.

within the next 7 days basic auth will be deactivated, so we need a solution soon....

@francescobianco
Copy link

@barbushin any plan to manage OAUTH?

@PauchardThomas
Copy link

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This will enhance this library. need help Your support is required to solve this issue. needs investigation This will be tested / debugged or checked out.
Projects
None yet
Development

No branches or pull requests

10 participants