PHPackages                             faysoft/fayoauth - 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. faysoft/fayoauth

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

faysoft/fayoauth
================

Faycms第三方登录模块

0.2.0(8y ago)01MITPHP

Since Jul 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/fayfox/fayoauth)[ Packagist](https://packagist.org/packages/faysoft/fayoauth)[ RSS](/packages/faysoft-fayoauth/feed)WikiDiscussions master Synced 2d ago

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

第三方登录模块
=======

[](#第三方登录模块)

此模块仅完成第三方登录信息获取，不涉及创建本地用户等业务逻辑操作。

调用代码
----

[](#调用代码)

```
//获取OAuth实例
$oauth = OauthService::getInstance(
    'weixin',//登录方式代码，对应services\oauth下的文件夹名
    {$app_id},//App Id
    {$app_secret}//App Secret
);
//获取openId
$open_id = $oauth->getOpenId();
//获取第三方用户
$user = $oauth->getUser();
//获取第三方用户字段
$user->getNickName();//获取第三方昵称
$user->getAvatar();//获取第三方头像链接
$user->getOpenId();//获取第三方对外id（Open Id）
$user->getUnionId();//获取第三方Union Id（微信登录可能会有这个值）
$user->getParam('city');//获取指定字段，根据第三方登录方式不同，字段有所差异
$user->getParams();//获取所有第三方返回的用户字段
```

代码介绍
----

[](#代码介绍)

- `ClientAbstract` 用于获取Access Token，state值校验等操作
- `AccessTokenAbstract` Access Token实例，可通过此实例获取用户信息
- `OauthService` 由于不同第三方登录参数略有区别，用OauthService来统一调用入口
    - `getAccessToken()` 获取Access Token（AccessTokenAbstract实例）
    - `getUser()` 获取第三方用户信息（返回UserAbstract实例）
    - `getOpenId()` 获取用户openId
- `UserAbstract` 第三方返回的用户信息各有不同，用此类来统一用户信息获取方法
    - `getAccessToken()` 获取Access Token值（字符串）
    - `getNickName()` 获取用户昵称
    - `getOpenId()` 获取用户openId
    - `getUnionId()` 获取用户UnionId。目前好像就微信有这个值
    - `getAvatar()` 获取用户头像
    - `getParams()` 获取所有原生第三方用户信息
    - `getParam($name)` 根据原生第三方用户信息字段获取用户信息
    - `__get()` 可以通过魔术方法调用`getParam()`
    - `ArrayAccess` 可以通过数组的方式调用`getParam()`
- `StateManager` 用于管理state

> 总结：`Client`和`AccessToken`类用于实现第三方登录。`OauthService`和`User`类用于统一调用和返回数据格式。

扩展登录方式时，需要实现`AccessTokenAbstract`, `ClientAbstract`, `OauthService`, `UserAbstract`类。

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Total

4

Last Release

3241d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/715c78792b69c79219be55b9a49579071e21c476978d99ca1670841c54e59d47?d=identicon)[fayfox](/maintainers/fayfox)

---

Top Contributors

[![fayfox](https://avatars.githubusercontent.com/u/10692848?v=4)](https://github.com/fayfox "fayfox (5 commits)")

---

Tags

oauthfaysoftfaycmsfayoauth

### Embed Badge

![Health badge](/badges/faysoft-fayoauth/health.svg)

```
[![Health](https://phpackages.com/badges/faysoft-fayoauth/health.svg)](https://phpackages.com/packages/faysoft-fayoauth)
```

###  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.7k143.0M274](/packages/league-oauth2-server)[league/oauth2-client

OAuth 2.0 Client Library

3.8k125.2M1.3k](/packages/league-oauth2-client)[league/oauth1-client

OAuth 1.0 Client Library

996106.2M115](/packages/league-oauth1-client)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

84217.7M77](/packages/knpuniversity-oauth2-client-bundle)[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42745.6M575](/packages/socialiteproviders-manager)[league/oauth2-google

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

42222.6M157](/packages/league-oauth2-google)

PHPackages © 2026

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