PHPackages                             mapkyca/known-oauth2-server - 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. mapkyca/known-oauth2-server

ActiveKnown-plugin[Authentication &amp; Authorization](/categories/authentication)

mapkyca/known-oauth2-server
===========================

Provides an OAuth2 authentication server for API calls

1.2.1(5y ago)79.7k↓50%2GPL-2.0PHPPHP &gt;=7.1CI failing

Since Aug 3Pushed 5y ago2 watchersCompare

[ Source](https://github.com/mapkyca/known-oauth2-server)[ Packagist](https://packagist.org/packages/mapkyca/known-oauth2-server)[ Docs](https://www.marcus-povey.co.uk)[ Fund](https://www.paypal.me/mapkyca)[ RSS](/packages/mapkyca-known-oauth2-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (17)Used By (0)

OAuth2 Server for Known
=======================

[](#oauth2-server-for-known)

\*\* EXPERIMENTAL \*\*

This plugin provides an OAuth2 Server for Known, allowing users to create applications and allow clients to authenticate themselves for the API and website using an OAuth2 access token.

This plugin is an experimental basic implementation of the spec, so please, kick it around and report any issues you find!

Usage
-----

[](#usage)

- Install in your plugins
- Create an application via settings
- Use the appropriate keys in your OAuth2 client

Support
-------

[](#support)

Currently the plugin supports:

- response\_type=code
- grant\_type=authorization\_code
- grant\_type=refresh\_token
- grant\_type=password
- state parameter validation
- scope support
- OpenID Connect

Example usage
-------------

[](#example-usage)

**To get a code:**

`https://mysite.com/oauth2/authorise/?response_type=code&client_id=&redirect_uri=`

You will be bounced to a login + authorisation page if necessary, so follow forwards.

As per the spec, you can omit the `redirect_uri`, in which case the response will be a straight json encoded blob. If `redirect_uri` is specified you will be forwarded to the endpoint, with appropriate parameters in the GET fields.

**To get a token:**

`https://mysite.com/oauth2/access_token/?grant_type=authorization_code&client_id=&redirect_uri=`

You should get back a json encoded blob with an access token, expiry and refresh token.

**To refresh a token:**

If your access token has expired, you can update it with the refresh token.

`https://mysite.com/oauth2/access_token/?grant_type=refresh_token&refresh_token=`

Success will spit back a new access token, refresh token and expiry. It also results in the destruction of the original token.

Accessing the token
-------------------

[](#accessing-the-token)

On a successful login the token used will be saved to the current session in `$_SESSION['oauth2_token']`, you can use this to check scope permissions, application ID and other details.

The scope granted to a given user is also saved against the user object in an array `$user->oauth2[$client_id]['scope']`, which is also cross checked on login.

Why not use native signed HTTP?
-------------------------------

[](#why-not-use-native-signed-http)

Natively, Known uses a per-user api key to sign requests, so why not use this?

Of course you can still, and the OAuth2 server doesn't replace that option. In many ways the signed HTTP approach is easier to get going, however...

1. There are many existing libraries for OAuth2 in pretty much every language.
2. With OAuth2 you give different credentials to each application. This means that if you no longer want to allow access from application A, but still want to keep B and C, you can revoke A's tokens specifically.

OpenID Connect
--------------

[](#openid-connect)

If you include the scope `openid`, on success the server will return an OpenID Connect signed JWT in the `id_token` field.

This token will include basic information about the authenticated user. If you also ask for `email` and `profile` scopes as well, you'll get some extra profile information back (email, full name, picture url, username, etc).

You can verify this token against the public key for the application (available from `https://yourserver.com/oauth2/CLIENTID/key`)

See
---

[](#see)

- Author: Marcus Povey
- OAuth2 Spec

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 98.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 ~42 days

Recently: every ~80 days

Total

16

Last Release

1844d ago

Major Versions

0.10.3 → 1.0.02020-02-03

PHP version history (2 changes)0.10.0PHP &gt;=7.2

0.10.1PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![mapkyca](https://avatars.githubusercontent.com/u/124070?v=4)](https://github.com/mapkyca "mapkyca (120 commits)")[![benwerd](https://avatars.githubusercontent.com/u/624104?v=4)](https://github.com/benwerd "benwerd (1 commits)")[![karadaisy](https://avatars.githubusercontent.com/u/950127?v=4)](https://github.com/karadaisy "karadaisy (1 commits)")

---

Tags

pluginknownoauth2

### Embed Badge

![Health badge](/badges/mapkyca-known-oauth2-server/health.svg)

```
[![Health](https://phpackages.com/badges/mapkyca-known-oauth2-server/health.svg)](https://phpackages.com/packages/mapkyca-known-oauth2-server)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[thenetworg/oauth2-azure

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

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

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