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

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

sunkangchina/oauth2-client
==========================

OAuth 2.0 Client Library

v2.8.0(1y ago)01MITPHPPHP ^5.6 || ^7.0 || ^8.0

Since Mar 25Pushed 1y agoCompare

[ Source](https://github.com/sunkangchina/oauth2-client)[ Packagist](https://packagist.org/packages/sunkangchina/oauth2-client)[ RSS](/packages/sunkangchina-oauth2-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (45)Used By (0)

OAuth 2.0 Client
================

[](#oauth-20-client)

composer.json
-------------

[](#composerjson)

```
"sunkangchina/oauth2-client": "^2"

```

支持京东oauth2非标准返回值
----------------

[](#支持京东oauth2非标准返回值)

```
$provider->setPkceCode($_SESSION['oauth2pkceCode']);
$provider->setLn([
    'access_token'=>'accessToken',
    'expires'=>'accessExpire',
    'refresh_token'=>'refreshToken',
    'refresh_expire'=>'refreshExpire',
]);
$accessToken = $provider->getAccessToken('authorization_code', [
    'code' => $_GET['code']
]);

```

也可以在`getAccessToken`前对方法进行优化

```
$provider->beforeParseJson(&$content);

```

原包信息
----

[](#原包信息)

This package provides a base for integrating with [OAuth 2.0](http://oauth.net/2/) service providers.

[![Gitter Chat](https://camo.githubusercontent.com/d5966c6ec9d0765b4cb7fcfed04fc777c6b436830f91288061d83b02cbf1ba5d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769747465722d6a6f696e5f636861742d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://gitter.im/thephpleague/oauth2-client)[![Source Code](https://camo.githubusercontent.com/7195d461877cfe1a2b8edc4b14418d8b3cd069e4e332c7f4bede9a3d3cebb767/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d7468657068706c65616775652f6f61757468322d2d636c69656e742d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth2-client)[![Latest Version](https://camo.githubusercontent.com/039e8e503af2d6fe76c16e2cd4801c4ac0997d31f00835015fc4a32682532074/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7468657068706c65616775652f6f61757468322d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth2-client/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth2-client/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/790aaec215db339202928e3c1b350aa75c45f8e669c9b42d74ab8aee9d6926e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7468657068706c65616775652f6f61757468322d636c69656e742f636f6e74696e756f75732d696e746567726174696f6e2e796d6c3f6c6162656c3d4349266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth2-client/actions?query=workflow%3ACI)[![Codecov Code Coverage](https://camo.githubusercontent.com/296e70c32273955a1166e5cb7a7e195f8d1f1103eab5c7ac5669449b09d840c3/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f7468657068706c65616775652f6f61757468322d636c69656e743f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/thephpleague/oauth2-client)[![Total Downloads](https://camo.githubusercontent.com/8ec673bbfdbeca8600bb35d811212d486eac7502a2939180ae70290d708db203/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f6f61757468322d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/oauth2-client)

---

The OAuth 2.0 login flow, seen commonly around the web in the form of "Connect with Facebook/Google/etc." buttons, is a common integration added to web applications, but it can be tricky and tedious to do right. To help, we've created the `league/oauth2-client` package, which provides a base for integrating with various OAuth 2.0 providers, without overburdening your application with the concerns of [RFC 6749](http://tools.ietf.org/html/rfc6749).

This OAuth 2.0 client library will work with any OAuth 2.0 provider that conforms to the OAuth 2.0 Authorization Framework. Out-of-the-box, we provide a `GenericProvider` class to connect to any service provider that uses [Bearer tokens](http://tools.ietf.org/html/rfc6750). See our [basic usage guide](https://oauth2-client.thephpleague.com/usage/) for examples using `GenericProvider`.

Many service providers provide additional functionality above and beyond the OAuth 2.0 specification. For this reason, you may extend and wrap this library to support additional behavior. There are already many [official](https://oauth2-client.thephpleague.com/providers/league/) and [third-party](https://oauth2-client.thephpleague.com/providers/thirdparty/) provider clients available (e.g., Facebook, GitHub, Google, Instagram, LinkedIn, etc.). If your provider isn't in the list, feel free to add it.

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), and [PSR-7](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md). If you notice compliance oversights, please send a patch via pull request. If you're interested in contributing to this library, please take a look at our [contributing guidelines](https://github.com/thephpleague/oauth2-client/blob/master/CONTRIBUTING.md).

Requirements
------------

[](#requirements)

We support the following versions of PHP:

- PHP 8.2
- PHP 8.1
- PHP 8.0
- PHP 7.4
- PHP 7.3
- PHP 7.2
- PHP 7.1
- PHP 7.0
- PHP 5.6

Provider Clients
----------------

[](#provider-clients)

We provide a list of [official PHP League provider clients](https://oauth2-client.thephpleague.com/providers/league/), as well as [third-party provider clients](https://oauth2-client.thephpleague.com/providers/thirdparty/).

To build your own provider client, please refer to "[Implementing a Provider Client](https://oauth2-client.thephpleague.com/providers/implementing/)."

Usage
-----

[](#usage)

For usage and code examples, check out our [basic usage guide](https://oauth2-client.thephpleague.com/usage/).

Contributing
------------

[](#contributing)

Please see [our contributing guidelines](https://github.com/thephpleague/oauth2-client/blob/master/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/thephpleague/oauth2-client/blob/master/LICENSE) for more information.

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance44

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~105 days

Recently: every ~412 days

Total

42

Last Release

472d ago

Major Versions

0.12.1 → 1.0.0-alpha12015-06-25

1.4.2 → 2.0.02017-01-13

PHP version history (6 changes)0.1PHP &gt;=5.3.0

0.4.0PHP &gt;=5.4.0

1.0.0-alpha1PHP &gt;=5.5.0

2.0.0PHP &gt;=5.6.0

2.3.0PHP ^5.6|^7.0

2.6.0PHP ^5.6 || ^7.0 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (409 commits)")[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (174 commits)")[![alexbilbie](https://avatars.githubusercontent.com/u/77991?v=4)](https://github.com/alexbilbie "alexbilbie (58 commits)")[![rtheunissen](https://avatars.githubusercontent.com/u/809191?v=4)](https://github.com/rtheunissen "rtheunissen (38 commits)")[![stevenmaguire](https://avatars.githubusercontent.com/u/1851973?v=4)](https://github.com/stevenmaguire "stevenmaguire (35 commits)")[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (16 commits)")[![jildertmiedema](https://avatars.githubusercontent.com/u/3383186?v=4)](https://github.com/jildertmiedema "jildertmiedema (15 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![bencorlett](https://avatars.githubusercontent.com/u/181919?v=4)](https://github.com/bencorlett "bencorlett (11 commits)")[![jrfnl](https://avatars.githubusercontent.com/u/663378?v=4)](https://github.com/jrfnl "jrfnl (9 commits)")[![TomHAnderson](https://avatars.githubusercontent.com/u/493920?v=4)](https://github.com/TomHAnderson "TomHAnderson (8 commits)")[![jamesmills](https://avatars.githubusercontent.com/u/557096?v=4)](https://github.com/jamesmills "jamesmills (8 commits)")[![adam-paterson](https://avatars.githubusercontent.com/u/1008727?v=4)](https://github.com/adam-paterson "adam-paterson (7 commits)")[![tpavlek](https://avatars.githubusercontent.com/u/782576?v=4)](https://github.com/tpavlek "tpavlek (7 commits)")[![msurguy](https://avatars.githubusercontent.com/u/585833?v=4)](https://github.com/msurguy "msurguy (6 commits)")[![jasonvarga](https://avatars.githubusercontent.com/u/105211?v=4)](https://github.com/jasonvarga "jasonvarga (5 commits)")[![SammyK](https://avatars.githubusercontent.com/u/578780?v=4)](https://github.com/SammyK "SammyK (5 commits)")[![aripringle](https://avatars.githubusercontent.com/u/1278449?v=4)](https://github.com/aripringle "aripringle (5 commits)")[![jeremykendall](https://avatars.githubusercontent.com/u/288613?v=4)](https://github.com/jeremykendall "jeremykendall (5 commits)")[![rakeev](https://avatars.githubusercontent.com/u/1861570?v=4)](https://github.com/rakeev "rakeev (4 commits)")

---

Tags

AuthenticationSSOidentityoauthoauth2authorizationidpsingle sign on

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[league/oauth2-client

OAuth 2.0 Client Library

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

PHPackages © 2026

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