PHPackages                             weida/oauth2-core - 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. weida/oauth2-core

ActiveLibrary

weida/oauth2-core
=================

v0.0.3(2y ago)0424MITPHPPHP &gt;=8.0

Since Aug 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/weida100/oauth2-core)[ Packagist](https://packagist.org/packages/weida/oauth2-core)[ RSS](/packages/weida-oauth2-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (4)

oauth2-core
===========

[](#oauth2-core)

oauth2授权通用核心 （ oauth2 Authorization Common core ）

Install
-------

[](#install)

```
composer require weida/oauth2-core
```

Demo
----

[](#demo)

```
use Weida\Oauth2Core\AbstractApplication;
use Weida\Oauth2Core\Contract\UserInterface;
use Weida\Oauth2Core\User;

class GitHub extends AbstractApplication {

    protected function getAuthUrl(): string{
        //your code
    }

    protected function getTokenUrl(string $code):string {
        //your code
    }

    protected function getUserInfoUrl(string $accessToken): string {
       //your code
    }

    public function userFromToken(string $accessToken): UserInterface {
        // demo code
        $url = $this->getUserInfoUrl($accessToken);
        //http get,post
        $resp = $this->getHttpClient()->request('GET',$url);
        if($resp->getStatusCode()!=200){
             throw new RuntimeException('Request userinfo exception');
        }
        $userinfo = json_decode($resp->getBody()->getContents(),true);
        if (empty($userinfo)) {
            throw new RuntimeException('Failed to get userinfo: ' . json_encode($arr, JSON_UNESCAPED_UNICODE));
        }
        return new User($userinfo);
    }

    public function userFromCode(string $code): UserInterface
     {
         // demo code
         $tokenArr = $this->tokenFromCode($code);
         return $this->userFromToken($tokenArr['access_token']);
     }
}

$github = new GitHub([
    'client_id' => 'aaaaaa',
    'client_secret' => 'bbbbbbbbbbb',
    'redirect'=>'http://127.0.0.1/a',
]);

echo $github->redirect();
$code = "xxxxxxx";
print_r($github->userFromCode($code)->getAttribute());
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% 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 ~41 days

Total

3

Last Release

923d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6470f67a7fa34860c4297836c0490b45a9da2f14607a7d30221101756b69ea22?d=identicon)[Sgenmi](/maintainers/Sgenmi)

---

Top Contributors

[![Sgenmi](https://avatars.githubusercontent.com/u/3337501?v=4)](https://github.com/Sgenmi "Sgenmi (17 commits)")[![weida100](https://avatars.githubusercontent.com/u/133979556?v=4)](https://github.com/weida100 "weida100 (1 commits)")

### Embed Badge

![Health badge](/badges/weida-oauth2-core/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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