Commit 4f0089bb by Klimov Paul

Microsoft Live OAuth2 client added.

parent 7f0ab92d
...@@ -209,7 +209,6 @@ class AuthAction extends Action ...@@ -209,7 +209,6 @@ class AuthAction extends Action
if ($response instanceof Response) { if ($response instanceof Response) {
return $response; return $response;
} }
return $this->redirectSuccess(); return $this->redirectSuccess();
} }
...@@ -233,7 +232,6 @@ class AuthAction extends Action ...@@ -233,7 +232,6 @@ class AuthAction extends Action
]; ];
$response = Yii::$app->getResponse(); $response = Yii::$app->getResponse();
$response->content = Yii::$app->getView()->renderFile($viewFile, $viewData); $response->content = Yii::$app->getView()->renderFile($viewFile, $viewData);
return $response; return $response;
} }
...@@ -247,7 +245,6 @@ class AuthAction extends Action ...@@ -247,7 +245,6 @@ class AuthAction extends Action
if ($url === null) { if ($url === null) {
$url = $this->getSuccessUrl(); $url = $this->getSuccessUrl();
} }
return $this->redirect($url); return $this->redirect($url);
} }
...@@ -261,7 +258,6 @@ class AuthAction extends Action ...@@ -261,7 +258,6 @@ class AuthAction extends Action
if ($url === null) { if ($url === null) {
$url = $this->getCancelUrl(); $url = $this->getCancelUrl();
} }
return $this->redirect($url, false); return $this->redirect($url, false);
} }
...@@ -292,7 +288,6 @@ class AuthAction extends Action ...@@ -292,7 +288,6 @@ class AuthAction extends Action
} }
} else { } else {
$url = $client->buildAuthUrl(); $url = $client->buildAuthUrl();
return Yii::$app->getResponse()->redirect($url); return Yii::$app->getResponse()->redirect($url);
} }
...@@ -325,7 +320,6 @@ class AuthAction extends Action ...@@ -325,7 +320,6 @@ class AuthAction extends Action
} else { } else {
// Upgrade to access token. // Upgrade to access token.
$client->fetchAccessToken(); $client->fetchAccessToken();
return $this->authSuccess($client); return $this->authSuccess($client);
} }
} }
...@@ -366,7 +360,6 @@ class AuthAction extends Action ...@@ -366,7 +360,6 @@ class AuthAction extends Action
} }
} else { } else {
$url = $client->buildAuthUrl(); $url = $client->buildAuthUrl();
return Yii::$app->getResponse()->redirect($url); return Yii::$app->getResponse()->redirect($url);
} }
} }
......
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\authclient\clients;
use yii\authclient\OAuth2;
/**
* Live allows authentication via Microsoft Live OAuth.
*
* In order to use Microsoft Live OAuth you must register your application at <https://account.live.com/developers/applications>
*
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'live' => [
* 'class' => 'yii\authclient\clients\Live',
* 'clientId' => 'live_client_id',
* 'clientSecret' => 'live_client_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see https://account.live.com/developers/applications
* @see http://msdn.microsoft.com/en-us/library/live/hh243647.aspx
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/
class Live extends OAuth2
{
/**
* @inheritdoc
*/
public $authUrl = 'https://login.live.com/oauth20_authorize.srf';
/**
* @inheritdoc
*/
public $tokenUrl = 'https://login.live.com/oauth20_token.srf';
/**
* @inheritdoc
*/
public $apiBaseUrl = 'https://apis.live.net/v5.0';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->scope === null) {
$this->scope = implode(',', [
'wl.basic',
'wl.emails',
]);
}
}
/**
* @inheritdoc
*/
protected function initUserAttributes()
{
return $this->api('me', 'GET');
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'live';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Live';
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment