istvan0304 / yii2-office365-oauth
Office 365 login for yii2 app
Installs: 309
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-authclient: *
This package is not auto-updated.
Last update: 2025-04-17 21:08:23 UTC
README
Requirements
- php >=7.2
Installation
The preferred way to install this extension is through composer.
-
Run
$ php composer.phar require istvan0304/yii2-office365-oauth "dev-master"
or add:
"istvan0304/yii2-office365-oauth": "dev-master"
to the require section of your application's composer.json file.
Usage
-
In controller apply:
public function actions() { return [ 'o365auth' => [ 'class' => 'cranedev\authclientO365\Office365AuthAction', 'successCallback' => [$this, 'onAuthSuccess'], ], ]; } public function onAuthSuccess($client) { // Handle login... }
-
In view:
<?= AuthChoice::widget([ 'baseAuthUrl' => ['site/o365auth'], 'popupMode' => false, ]) ?>
OR create a link
-
Set Environment variables
-
Setup http client
return [ 'components' => [ 'authClientCollection' => [ 'class' => 'yii\authclient\Collection', 'clients' => [ 'o365' => [ 'class' => 'istvan0304\yii2office365oauth\src\Office365OAuth', 'clientId' => getenv('AUTH_CLIENT_ID'), 'clientSecret' => getenv('AUTH_CLIENT_SECRET'), 'authUrl' => getenv('AUTH_URL'), 'tokenUrl' => getenv('AUTH_TOKEN_URL'), 'apiBaseUrl' => getenv('GRAPH_URL'), 'returnUrl' => getenv('AUTH_RETURN_URL'), 'scope' => getenv('AUTH_SCOPE'), 'resource' => getenv('AUTH_RESOURCE_URL'), 'title' => 'Title', // 'login_hint' => '', 'selectParams' => 'id,displayName,userPrincipalName,mail,photo,mobilePhone,preferredLanguage,onPremisesExtensionAttributes', //'proxy' => getenv('AUTH_PROXY_URL'), ], ], //... ], // ... ];
-