itmages/yii-eoauth

此包已被废弃且不再维护。未建议替代包。

Yii框架扩展。EOAuthUserIdentity类实现了IUserIdentity Yii接口和OAuth协议,用于用户身份验证。基于Google的软件。

1.0.2 2017-05-29 17:41 UTC

This package is not auto-updated.

Last update: 2018-04-29 12:19:24 UTC


README

EOAuthUserIdentity类实现了IUserIdentity Yii接口和OAuth协议来验证用户。

基于Google的软件。

Flattr this git repo

###资源

##文档

###需求

  • Yii 1.0或更高版本

###安装

  • protected/extensions/eoauth下提取发行文件

###使用

使用以下示例操作与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);
    }

在main.php中设置加载扩展(由DavidHHuan,感谢!)

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

许可证

以前我为了InDaHouseRulez SL开发了此扩展。我不再那里工作,但我仍然支持此扩展。

此扩展在MIT许可证下发布,因此我在GitHub上创建了一个分支,您可以在这里找到最新版本

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