Permalink
Browse files

Added Microsoft Live OAuth provider. #18

  • Loading branch information...
1 parent 86efaf4 commit ec51feb1b2a11dc64243240c5b729786fe7cdb23 @Nodge committed Jun 11, 2012
Showing with 63 additions and 0 deletions.
  1. +1 −0 CHANGELOG.md
  2. +1 −0 assets/css/auth.css
  3. BIN assets/images/auth.png
  4. +61 −0 services/LiveOAuthService.php
View
@@ -2,6 +2,7 @@ Yii EAuth Change Log
====================
### In progress...
+* Added Microsoft Live OAuth provider.
### Version 1.1.8 (10.06.2012)
View
@@ -21,6 +21,7 @@
.auth-icon.odnoklassniki { background-position: 0 -272px; }
.auth-icon.linkedin { background-position: 0 -306px; }
.auth-icon.github { background-position: 0 -340px; }
+.auth-icon.live { background-position: 0 -372px; }
.auth-link:hover .auth-icon i,
.auth-link:focus .auth-icon i {
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,61 @@
+<?php
+/**
+ * LiveOAuthService class file.
+ *
+ * Register application: https://manage.dev.live.com/Applications/Index
+ *
+ * @author https://github.com/pavlepredic
+ * @link https://github.com/Nodge/yii-eauth/
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ */
+
+require_once dirname(dirname(__FILE__)).'/EOAuth2Service.php';
+
+/**
+ * Microsoft Live provider class.
+ * @package application.extensions.eauth.services
+ */
+class LiveOAuthService extends EOAuth2Service {
+
+ protected $name = 'live';
+ protected $title = 'Live';
+ protected $type = 'OAuth';
+ protected $jsArguments = array('popup' => array('width' => 900, 'height' => 450));
+
+ protected $client_id = '';
+ protected $client_secret = '';
+ protected $scope = 'wl.emails';
+ protected $providerOptions = array(
+ 'authorize' => 'https://login.live.com/oauth20_authorize.srf',
+ 'access_token' => 'https://login.live.com/oauth20_token.srf',
+ );
+
+ protected function fetchAttributes() {
+ $info = (object) $this->makeSignedRequest('https://apis.live.net/v5.0/me');
+
+ $this->attributes['id'] = $info->id;
+ $this->attributes['name'] = $info->name;
+ $this->attributes['url'] = 'https://profile.live.com/cid-'.$info->id.'/';
+
+ /*$this->attributes['email'] = $info->emails->account;
+ $this->attributes['first_name'] = $info->first_name;
+ $this->attributes['last_name'] = $info->last_name;
+ $this->attributes['gender'] = $info->gender;
+ $this->attributes['locale'] = $info->locale;*/
+ }
+
+ protected function getTokenUrl($code) {
+ return parent::getTokenUrl($code).'&grant_type=authorization_code&redirect_uri='.urlencode($this->getState('redirect_uri'));
+ }
+
+ protected function getAccessToken($code) {
+ //live returns an instance of stdClass as access token; the actual token is stored as access_token property
+ return $this->makeRequest($this->getTokenUrl($code))->access_token;
+ }
+
+ protected function getCodeUrl($redirectUri) {
+ //store redirect uri in session; we need to use it when requesting an access token
+ $this->setState('redirect_uri', $redirectUri);
+ return parent::getCodeUrl($redirectUri);
+ }
+}

0 comments on commit ec51feb

Please sign in to comment.