This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
plugin:oauth2 [2022/11/19 08:41] duncanc [Logging HTTP requests and responses] |
plugin:oauth2 [2023/10/19 08:19] (current) duncanc [The Settings page] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== OAuth2 plugin ====== | ||
+ | |||
+ | ---- plugin ---- | ||
+ | description: | ||
+ | author | ||
+ | type : | ||
+ | lastupdate : 2022/11/08 21:19 | ||
+ | compatible : | ||
+ | depends | ||
+ | conflicts | ||
+ | similar | ||
+ | tags : | ||
+ | |||
+ | downloadurl: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Purpose ===== | ||
+ | |||
+ | This plugin uses OAuth2 to access the mailbox for processing bounces and for sending email using SMTP. Currently it supports OAuth2 for only Microsoft Office365 / Outlook. | ||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | You need to enable Common Plugin before enabling this plugin and should update Common Plugin to the latest version. On the Manage Plugins page use this package URL | ||
+ | https:// | ||
+ | |||
+ | Install this plugin using the package URL | ||
+ | https:// | ||
+ | |||
+ | |||
+ | |||
+ | ===== Configuration ===== | ||
+ | |||
+ | ==== Change to config.php ==== | ||
+ | |||
+ | The OAuth2 Redirect URL is used to pass control back to the application, | ||
+ | |||
+ | <code php> | ||
+ | // for OAuth2 plugin | ||
+ | if (isset($_GET[' | ||
+ | ini_set(' | ||
+ | setcookie( | ||
+ | ' | ||
+ | $_COOKIE[' | ||
+ | [' | ||
+ | ); | ||
+ | session_start(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== The Settings page ==== | ||
+ | |||
+ | After enabling the plugin there will be an OAuth2 group on the Settings page. You need to enter the fields used when registering the application with Microsoft | ||
+ | |||
+ | * Tenant Id | ||
+ | * Client Id | ||
+ | * Client Secret | ||
+ | * Redirect URl - this needs to be the URL of a specific page provided by the plugin. | ||
+ | |||
+ | |||
+ | If phplist is installed in the default location then the URL will be similar to this, otherwise adjust for the actual location | ||
+ | https:// | ||
+ | |||
+ | You can select to use OAuth2, instead of the normal password verification, | ||
+ | Currently the plugin supports having an access token for only one email address, so that email address would need to be used for both sending and receiving emails if this setting is set to Yes. | ||
+ | |||
+ | The plugin previously had settings for the IMAP mailbox/ | ||
+ | |||
+ | |||
+ | ===== Usage ===== | ||
+ | |||
+ | The plugin adds two pages to the System menu | ||
+ | |||
+ | **OAuth2 access token ** - this page shows an existing access token and its expiry time. You can sign-in to create a new access token or refresh the current token. | ||
+ | When you sign-in it must be with the email address used in config.php %%$bounce_mailbox_user%% | ||
+ | |||
+ | **Process bounces using OAuth2** - this page will run the phplist processbounces page but will use the access token instead of a password. The php IMAP extension need not be enabled, although this page should work even when IMAP is enabled. | ||
+ | |||
+ | In the config.php file the value for %%$bounce_mailbox_password%% does not matter because it will be replaced by the access token. | ||
+ | |||
+ | The page will refresh the access token if it has already expired. | ||
+ | |||
+ | The page can also be run from the command line | ||
+ | |||
+ | php / | ||
+ | | ||
+ | or as a remote page using curl or wget similar to this | ||
+ | |||
+ | curl ' | ||
+ | |||
+ | |||
+ | === Send emails using OAuth2 === | ||
+ | |||
+ | When the configuration setting is enabled, OAuth2 authentication will be used instead of password authentication when sending emails. | ||
+ | |||
+ | ===== Logging HTTP requests and responses ===== | ||
+ | |||
+ | The plugin can log the HTTP requests made and responses received. | ||
+ | |||
+ | Add the following to the config.php file (at the end of the file is ok) | ||
+ | |||
+ | <code php> | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ], | ||
+ | ];</ | ||
+ | |||
+ | Now requests and responses will be logged to a file in the phplist temporary directory, identfied by the '' | ||
+ | |||
+ | Alternatively you can specify a particular directory for the log file. The directory must be writeable by the web server process. | ||
+ | |||
+ | <code php> | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ], | ||
+ | ' | ||
+ | ];</ | ||
+ | |||
+ | Each query will be logged similar to this | ||
+ | |||
+ | < | ||
+ | [Fri 18 Nov 2022 15:22:07] [debug] GuzzleHttp\Promise\FulfilledPromise:: | ||
+ | Request GET https:// | ||
+ | [Fri 18 Nov 2022 15:22:07] [debug] GuzzleHttp\Promise\Promise:: | ||
+ | Response 200 {" | ||
+ | |||
+ | </ | ||
+ | |||
+ | To stop logging simply change DEBUG to OFF. | ||
+ | |||