eoauth

EOAuth implements the OAuth protocol.
14 followers

Introduction

EOAuthUserIdentity class implements IUserIdentity Yii interface and the OAuth protocol to authenticate a user.

Based on Google's software.

Download

Download Last release

Resources

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/extensions/eoauth

Usage

Use this sample actions for login/logout with Google:

public function actionLogin() {
 
        Yii::import('ext.eoauth.*');
 
        $ui = new EOAuthUserIdentity(
                array(
                    //Set the "scope" to the service you want to use
                        'scope'=>'https://sandbox.google.com/apis/ads/publisher/',
                        'provider'=>array(
                                'request'=>'https://www.google.com/accounts/OAuthGetRequestToken',
                                'authorize'=>'https://www.google.com/accounts/OAuthAuthorizeToken',
                                'access'=>'https://www.google.com/accounts/OAuthGetAccessToken',
                        )
                )
        );
 
        if ($ui->authenticate()) {
            $user=Yii::app()->user;
            $user->login($ui);
            $this->redirect($user->returnUrl);
        }
        else throw new CHttpException(401, $ui->error);
 
    }
 
 
 
    public function actionLogout() {
 
        Yii::app()->user->logout();
 
        // Redirect to application home page.
        $this->redirect(Yii::app()->homeUrl);
    }

License

Some time ago I developed this extension for InDaHouseRulez SL. I no longer work there, but I still support the extension.

The extension was released under the MIT license, so I made a fork on GitHub, where you'll find the latest version:

https://github.com/jorgebg/yii-eoauth

Change Log

September 10, 2010

  • Initial release.

Total 5 comments

#5959 report it
Nashi at 2011/11/30 06:03am
POST?

How to make it work with POST requests instead of GETs?

#4365 report it
Burzum at 2011/06/29 05:00am
Question

That's work fine for the authentification, but what about calling services after? Like http://api.linkedin.com/v1/people/~

Is it possible with your extention?

#4356 report it
Burzum at 2011/06/28 11:26am
Thank you!!!

You saved my life!! I'm using your classes to connect with Linkedin, that works fine!!

#4283 report it
idrozd at 2011/06/21 10:00pm
Would it work with ouath2?

Huh?

#1930 report it
DavidHHuan at 2010/10/17 07:27am
avoid meeting PHP standard issue

Hi,CGeorge, following your guide to test this extension, there is an issue after i logining and allowing in google to use oauth

EOAuthUserIdentity::authenticate() [<a href='eoauthuseridentity.authenticate'>eoauthuseridentity.authenticate</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;OAuthToken&quot; of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition

That is a standard PHP deserialization issue.

The way to avoid this issue is that, set to load the extensions in the main.php

'import'=>array(
    'application.models.*',
    'application.components.*',
        'ext.eoauth.*',
        'ext.eoauth.lib.*',
),

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet
  • License: MIT License
  • Developed by: CGeorge
  • Category: Auth
  • Votes: +8
  • Downloaded: 536 times
  • Created on: Sep 10, 2010
  • Last updated: Aug 26, 2011