PHPackages                             xj/yii2-oauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. xj/yii2-oauth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

xj/yii2-oauth
=============

yii2-oauth

2.0.4(6y ago)10927.8k—0%42[1 PRs](https://github.com/xjflyttp/yii2-oauth/pulls)1BSD-3-ClausePHP

Since Aug 8Pushed 5y ago16 watchersCompare

[ Source](https://github.com/xjflyttp/yii2-oauth)[ Packagist](https://packagist.org/packages/xj/yii2-oauth)[ RSS](/packages/xj-yii2-oauth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (1)

yii2-oauth
==========

[](#yii2-oauth)

===

### composer.json

[](#composerjson)

---

```
"require": {
        "xj/yii2-oauth": "~2.0.0"
},
```

### config

[](#config)

---

```
'components' => [
    'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'qq' => [
                'class' => 'xj\oauth\QqAuth',
                'clientId' => '111',
                'clientSecret' => '111',

            ],
            'weibo' => [
                'class' => 'xj\oauth\WeiboAuth',
                'clientId' => '111',
                'clientSecret' => '111',
            ],
            'weixin' => [
                'class' => 'xj\oauth\WeixinAuth',
                'clientId' => '111',
                'clientSecret' => '111',
            ],
            'renren' => [
                'class' => 'xj\oauth\RenrenAuth',
                'clientId' => '111',
                'clientSecret' => '111',
            ],
            'douban' => [
                'class' => 'xj\oauth\DoubanAuth',
                'clientId' => '111',
                'clientSecret' => '111',
            ],
            'weixin-mp' => [
                'class' => 'xj\oauth\WeixinMpAuth',
                'clientId' => '111',
                'clientSecret' => '111',
            ],
            'amazon' => [
                'class' => 'xj\oauth\AmazonAuth',
                'clientId' => '',
                'clientSecret' => '',
            ],
        ]
    ]
    ...
]
```

### Controller

[](#controller)

---

```
class SiteController extends Controller
{
    public function actions()
    {
        return [
            'auth' => [
                'class' => 'yii\authclient\AuthAction',
                'successCallback' => [$this, 'successCallback'],
            ],
        ];
    }

    /**
     * Success Callback
     * @param QqAuth|WeiboAuth $client
     * @see http://wiki.connect.qq.com/get_user_info
     * @see http://stuff.cebe.cc/yii2docs/yii-authclient-authaction.html
     */
    public function successCallback($client) {
        $id = $client->getId(); // qq | sina | weixin
        $attributes = $client->getUserAttributes(); // basic info
        $openid = $client->getOpenid(); //user openid
        $userInfo = $client->getUserInfo(); // user extend info
        var_dump($id, $attributes, $openid, $userInfo);
    }
}
```

### View

[](#view)

---

```

```

### WeixinMp

[](#weixinmp)

```
$weixinMp = Yii::$app->authClientCollection->getClient('weixin-mp');

// http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html
// getAccessToken
$accessTokenResult = $weixinMp->getMpAccessToken();
if ($accessTokenResult->validate()) {
    $accessTokenResult->access_token;
    $accessTokenResult->expires_in;
    $accessTokenResult->getAccessToken(); // WeixinMpToken
} else {
    var_dump($accessTokenResult->getErrCodeText());
    var_dump($accessTokenResult->getErrors());
}

// http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E8.8E.B7.E5.8F.96api_ticket
// getTicket
$accessTokenResult = $weixinMp->getMpAccessToken();
$ticketType = 'jsapi'; // wx_card
$ticketResult = $weixinMp->getTicket($accessTokenResult->access_token, $ticketType);
if ($ticketResult->validate()) {
    $accessTokenResult->ticket; // TicketString
} else {
    var_dump($ticketResult->getErrCodeText());
    var_dump($ticketResult->getErrors());
}
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 83.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~230 days

Recently: every ~336 days

Total

10

Last Release

2216d ago

Major Versions

1.0.4 → 2.0.02016-08-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/f9f04ccc1ccda3af80975323425ff7d5f7d142603f1ad05df6558ffa63256f8d?d=identicon)[xjflyttp](/maintainers/xjflyttp)

---

Top Contributors

[![xjflyttp](https://avatars.githubusercontent.com/u/128428?v=4)](https://github.com/xjflyttp "xjflyttp (31 commits)")[![lichunqiang](https://avatars.githubusercontent.com/u/2433916?v=4)](https://github.com/lichunqiang "lichunqiang (4 commits)")[![fnsoxt](https://avatars.githubusercontent.com/u/174951?v=4)](https://github.com/fnsoxt "fnsoxt (1 commits)")[![funson86](https://avatars.githubusercontent.com/u/6244263?v=4)](https://github.com/funson86 "funson86 (1 commits)")

### Embed Badge

![Health badge](/badges/xj-yii2-oauth/health.svg)

```
[![Health](https://phpackages.com/badges/xj-yii2-oauth/health.svg)](https://phpackages.com/packages/xj-yii2-oauth)
```

###  Alternatives

[budyaga/yii2-users

Module for manage users and their rights with the support of registration through social services and assigned to each user more than one social service.

409.1k](/packages/budyaga-yii2-users)[lowbase/yii2-user

Yii2 user module

131.5k2](/packages/lowbase-yii2-user)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
