Add Mailium Service Provider to providers array in config/app.php
MailiumOauthClient\MailiumOauthClientLaravel\MailiumOauthClientServiceProvider::class,
Add Mailium Facade to aliases array in config/app.php
'MailiumOauthClient' => MailiumOauthClient\MailiumOauthClientLaravel\MailiumOauthClientFacade::class,
Add Mailium Middleware to the middleware group array in app/Http/Kernel.php
\MailiumOauthClient\MailiumOauthClientLaravel\MailiumOauthClientMiddleware::class,
Example:
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\MailiumOauthClient\MailiumOauthClientLaravel\MailiumOauthClientMiddleware::class,
],
php artisan vendor:publish
php artisan migrate
Configure your client_id, client_secret, required scopes and app type on config/mailium-oauth.php file.
Oauth client middleware adds four attributes to the incoming requests
- mailium_app_accid (account identifier)
- mailium_app_user (mailium app user object)
- mailium_app_just_installed (boolean variable defines if the app is just installed and the request is first one )
- mailium_api_client (API wrapper)
$this->accId = $request->attributes->get('mailium_app_accid');
$this->mailiumAppUser = $request->attributes->get('mailium_app_user');
$this->justInstalled = $request->attributes->get('mailium_app_just_installed');
$this->apiClient = $request->attributes->get('mailium_api_client');
$this->apiClient->run('List.GetList',array());