PHPackages                             techleeone/oauth2-client - 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. techleeone/oauth2-client

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

techleeone/oauth2-client
========================

oauth2-client

v1.0.1(8y ago)2551MITPHPPHP &gt;=5.4.0

Since Apr 2Pushed 8y agoCompare

[ Source](https://github.com/leeqvip/oauth2-client)[ Packagist](https://packagist.org/packages/techleeone/oauth2-client)[ RSS](/packages/techleeone-oauth2-client/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

OAuth2-Client
=============

[](#oauth2-client)

OAuth 是针对访问授权的一个开放标准，它正通过许多实现（包括针对Spring Security的一个实现）而不断获得动力。

### 安装

[](#安装)

```
composer require techleeone/oauth2-client

```

### 使用

[](#使用)

```
// 如果是使用支持composer自动加载的框架（比如thinkphp，laravel），则无需require。
require_once dirname(__FILE__) . '/vendor/autoload.php';

use TechOne\OAuth2\Client\Provider;

$config = [
    // 应用ID | 公众号的唯一标识appid
    'client_id' => '',
    // 应用私钥 |  公众号的appsecret
    'client_secret' => '',
    // 回调地址
    'redirect_uri' => '',
    // 授权登录页面地址
    'authorize_url' => '',
    // 获取AccessToken地址
    'access_token_url' => '',
];
$token = Provider::create($config)->getAccessToken();
```

#### 微信网页授权

[](#微信网页授权)

```
$token = Provider::create($config, 'wechat')->getAccessToken();
```

#### 开源中国（oschina）认证接口

[](#开源中国oschina认证接口)

```
$token = Provider::create($config, 'oschina')->getAccessToken();
```

#### 扩展

[](#扩展)

您可以自行扩展其他平台的oauth2认证接口，必须继承 `TechOne\OAuth2\Client\Providers\AbstractProvider` 。

例如：

```
namespace YourNamespace;

use TechOne\OAuth2\Client\Providers\AbstractProvider;
use TechOne\OAuth2\Client\Provider;

class YourOauth2Provider extends AbstractProvider
{
    public function getAuthorizeData()
    {
        return [
            'client_id'     => $this->clientId,
            'redirect_uri'  => $this->redirectUri,
            'response_type' => $this->responseType,
            'state'         => $this->getState(),
        ];
    }

    public function getAccessTokenData($code)
    {
        return [
            'client_id'     => $this->clientId,
            'client_secret' => $this->clientSecret,
            'grant_type'    => 'authorization_code',
            'redirect_uri'  => $this->redirectUri,
            'code'          => $code,
            'dataType'      => 'json',
        ];
    }
}

$token = Provider::create($config, '\\YourNamespace\\YourOauth2Provider')->getAccessToken();
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

2967d ago

### Community

Maintainers

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

---

Top Contributors

[![leeqvip](https://avatars.githubusercontent.com/u/35752209?v=4)](https://github.com/leeqvip "leeqvip (3 commits)")

---

Tags

oauth2

### Embed Badge

![Health badge](/badges/techleeone-oauth2-client/health.svg)

```
[![Health](https://phpackages.com/badges/techleeone-oauth2-client/health.svg)](https://phpackages.com/packages/techleeone-oauth2-client)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[league/oauth2-client

OAuth 2.0 Client Library

3.8k118.6M1.2k](/packages/league-oauth2-client)[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)

PHPackages © 2026

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