Browse Source

Microsoft Live OAuth2 client added.

tags/2.0.0-beta
Klimov Paul 11 years ago
parent
commit
4f0089bb0d
  1. 7
      extensions/authclient/AuthAction.php
  2. 93
      extensions/authclient/clients/Live.php

7
extensions/authclient/AuthAction.php

@ -209,7 +209,6 @@ class AuthAction extends Action
if ($response instanceof Response) {
return $response;
}
return $this->redirectSuccess();
}
@ -233,7 +232,6 @@ class AuthAction extends Action
];
$response = Yii::$app->getResponse();
$response->content = Yii::$app->getView()->renderFile($viewFile, $viewData);
return $response;
}
@ -247,7 +245,6 @@ class AuthAction extends Action
if ($url === null) {
$url = $this->getSuccessUrl();
}
return $this->redirect($url);
}
@ -261,7 +258,6 @@ class AuthAction extends Action
if ($url === null) {
$url = $this->getCancelUrl();
}
return $this->redirect($url, false);
}
@ -292,7 +288,6 @@ class AuthAction extends Action
}
} else {
$url = $client->buildAuthUrl();
return Yii::$app->getResponse()->redirect($url);
}
@ -325,7 +320,6 @@ class AuthAction extends Action
} else {
// Upgrade to access token.
$client->fetchAccessToken();
return $this->authSuccess($client);
}
}
@ -366,7 +360,6 @@ class AuthAction extends Action
}
} else {
$url = $client->buildAuthUrl();
return Yii::$app->getResponse()->redirect($url);
}
}

93
extensions/authclient/clients/Live.php

@ -0,0 +1,93 @@
<?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';
}
}
Loading…
Cancel
Save