Skip to content


Subversion checkout URL

You can clone with
Download ZIP
EAuth extension allows to authenticate users by the OpenID, OAuth 1.0 and OAuth 2.0 providers.
PHP CSS JavaScript
Tree: 92aca24c73

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Yii EAuth extension

EAuth extension allows to authenticate users with accounts on other websites. Supported protocols: OpenID, OAuth 1.0 and OAuth 2.0.

EAuth is a extension for provide a unified (does not depend on the selected service) method to authenticate the user. So, the extension itself does not perform login, does not register the user and does not bind the user accounts from different providers.

Why own extension and not a third-party service?

The implementation of the authorization on your own server has several advantages:

  • Full control over the process: what will be written in the authorization window, what data we get, etc.
  • Ability to change the appearance of the widget.
  • When logging via OAuth is possible to invoke methods on API.
  • Fewer dependencies on third-party services - more reliable application.

The extension allows you to:

  • Ignore the nuances of authorization through the different types of services, use the class based adapters for each service.
  • Get a unique user ID that can be used to register user in your application.
  • Extend the standard authorization classes to obtain additional data about the user.
  • Work with the API of social networks by extending the authorization classes.
  • Set up a list of supported services, customize the appearance of the widget, use the popup window without closing your application.

Extension includes:

  • The component that contains utility functions.
  • A widget that displays a list of services in the form of icons and allowing authorization in the popup window.
  • Base classes to create your own services.
  • Ready for authenticate via Google, Twitter, Facebook and other providers.

Supported providers "out of box":

  • OpenID: Google, Yandex(ru)
  • OAuth: Twitter
  • OAuth 2.0: Google, Facebook, VKontake(ru),, Moi Krug(ru), Odnoklassniki(ru)




  • Install loid and EOAuth extensions
  • Extract the release file under protected/extensions
  • In your protected/config/main.php, add the following:
        'loid' => array(
            'class' => 'ext.lightopenid.loid',
        'eauth' => array(
            'class' => 'ext.eauth.EAuth',
            'popup' => true, // Use the popup window instead of redirecting.
            'services' => array( // You can change the providers and their classes.
                'google' => array(
                    'class' => 'GoogleOpenIDService',
                'yandex' => array(
                    'class' => 'YandexOpenIDService',
                'twitter' => array(
                    // register your app here:
                    'class' => 'TwitterOAuthService',
                    'key' => '...',
                    'secret' => '...',
                'google_oauth' => array(
                    // register your app here:
                    'class' => 'GoogleOAuthService',
                    'client_id' => '...',
                    'client_secret' => '...',
                    'title' => 'Google (OAuth)',
                'facebook' => array(
                    // register your app here:
                    'class' => 'FacebookOAuthService',
                    'client_id' => '...',
                    'client_secret' => '...',
                'linkedin' => array(
                    // register your app here:
                    'class' => 'LinkedinOAuthService',
                    'key' => '...',
                    'secret' => '...',
                'github' => array(
                    // register your app here:
                    'class' => 'GitHubOAuthService',
                    'client_id' => '...',
                    'client_secret' => '...',
                'vkontakte' => array(
                    // register your app here:
                    'class' => 'VKontakteOAuthService',
                    'client_id' => '...',
                    'client_secret' => '...',
                'mailru' => array(
                    // register your app here:
                    'class' => 'MailruOAuthService',
                    'client_id' => '...',
                    'client_secret' => '...',
                'moikrug' => array(
                    // register your app here:
                    'class' => 'MoikrugOAuthService',
                    'client_id' => '...',
                    'client_secret' => '...',
                'odnoklassniki' => array(
                    // register your app here:
                    'class' => 'OdnoklassnikiOAuthService',
                    'client_id' => '...',
                    'client_public' => '...',
                    'client_secret' => '...',
                    'title' => 'Odnokl.',


The action

    public function actionLogin() {
        $service = Yii::app()->request->getQuery('service');
        if (isset($service)) {
            $authIdentity = Yii::app()->eauth->getIdentity($service);
            $authIdentity->redirectUrl = Yii::app()->user->returnUrl;
            $authIdentity->cancelUrl = $this->createAbsoluteUrl('site/login');

            if ($authIdentity->authenticate()) {
                $identity = new EAuthUserIdentity($authIdentity);

                // successful authentication
                if ($identity->authenticate()) {

                    // special redirect with closing popup window
                else {
                    // close popup window and redirect to cancelUrl

            // Something went wrong, redirect to login page

        // default authorization code through login/password ..

The view

<h2>Do you already have an account on one of these sites? Click the logo to log in with it here:</h2>
    $this->widget('ext.eauth.EAuthWidget', array('action' => 'site/login'));

Getting more user data (optional)

To receive all the necessary data to your application, you can override the base class of any provider. Base classes are stored in protected/extensions/eauth/services/. Examples of extended classes can be found in protected/extensions/eauth/custom_services/.

After overriding the base class, you need to modify your configuration file to set new name of the class. Also you may need to override the EAuthUserIdentity class to store additional data.

Translations (optional)

  • Copy the file /protected/extensions/eauth/messages/[lang]/eauth.php to /protected/messages/[lang]/eauth.php to translate the EAuth extension into other languages.
  • To add a new language, you can use the blank file /protected/extensions/eauth/messages/blank/eauth.php.


Some time ago I developed this extension for and I still support the extension.

The extension was released under the New BSD License, so you'll find the latest version on GitHub.

Something went wrong with that request. Please try again.