PHPackages                             pzworks/openid-connect-php - 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. pzworks/openid-connect-php

ActiveLibrary

pzworks/openid-connect-php
==========================

Bare-bones OpenID Connect client

v0.8.2(6y ago)0833Apache-2.0PHPPHP &gt;=5.4

Since Sep 4Pushed 3y agoCompare

[ Source](https://github.com/pzworks/OpenID-Connect-PHP)[ Packagist](https://packagist.org/packages/pzworks/openid-connect-php)[ RSS](/packages/pzworks-openid-connect-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (4)Dependencies (3)Versions (17)Used By (0)

PHP OpenID Connect Basic Client
===============================

[](#php-openid-connect-basic-client)

A simple library that allows an application to authenticate a user through the basic OpenID Connect flow. This library hopes to encourage OpenID Connect use by making it simple enough for a developer with little knowledge of the OpenID Connect protocol to setup authentication.

A special thanks goes to Justin Richer and Amanda Anganes for their help and support of the protocol.

Requirements
============

[](#requirements)

1. PHP 5.4 or greater
2. CURL extension
3. JSON extension

Install
-------

[](#install)

1. Install library using composer

```
composer require pzworks/openid-connect-php

```

2. Include composer autoloader

```
require __DIR__ . '/vendor/autoload.php';
```

Example 1: Basic Client
-----------------------

[](#example-1-basic-client)

```
use pzworks\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->setCertPath('/path/to/my.cert');
$oidc->authenticate();
$name = $oidc->requestUserInfo('given_name');
```

[See openid spec for available user attributes](http://openid.net/specs/openid-connect-basic-1_0-15.html#id_res)

Example 2: Dynamic Registration
-------------------------------

[](#example-2-dynamic-registration)

```
use pzworks\OpenIDConnectClient;

$oidc = new OpenIDConnectClient("https://id.provider.com");

$oidc->register();
$client_id = $oidc->getClientID();
$client_secret = $oidc->getClientSecret();

// Be sure to add logic to store the client id and client secret
```

Example 3: Network and Security
-------------------------------

[](#example-3-network-and-security)

```
// Configure a proxy
$oidc->setHttpProxy("http://my.proxy.com:80/");

// Configure a cert
$oidc->setCertPath("/path/to/my.cert");
```

Example 4: Request Client Credentials Token
-------------------------------------------

[](#example-4-request-client-credentials-token)

```
use pzworks\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->providerConfigParam(array('token_endpoint'=>'https://id.provider.com/connect/token'));
$oidc->addScope('my_scope');

// this assumes success (to validate check if the access_token property is there and a valid JWT) :
$clientCredentialsToken = $oidc->requestClientCredentialsToken()->access_token;
```

Example 5: Request Resource Owners Token (with client auth)
-----------------------------------------------------------

[](#example-5-request-resource-owners-token-with-client-auth)

```
use pzworks\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->providerConfigParam(array('token_endpoint'=>'https://id.provider.com/connect/token'));
$oidc->addScope('my_scope');

//Add username and password
$oidc->addAuthParam(array('username'=>''));
$oidc->addAuthParam(array('password'=>''));

//Perform the auth and return the token (to validate check if the access_token property is there and a valid JWT) :
$token = $oidc->requestResourceOwnerToken(TRUE)->access_token;
```

Example 6: Basic client for implicit flow e.g. with Azure AD B2C (see [http://openid.net/specs/openid-connect-core-1\_0.html#ImplicitFlowAuth](http://openid.net/specs/openid-connect-core-1_0.html#ImplicitFlowAuth))
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#example-6-basic-client-for-implicit-flow-eg-with-azure-ad-b2c-see-httpopenidnetspecsopenid-connect-core-1_0htmlimplicitflowauth)

```
use pzworks\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->setResponseTypes(array('id_token'));
$oidc->addScope(array('openid'));
$oidc->setAllowImplicitFlow(true);
$oidc->addAuthParam(array('response_mode' => 'form_post'));
$oidc->setCertPath('/path/to/my.cert');
$oidc->authenticate();
$sub = $oidc->getVerifiedClaims('sub');
```

Example 7: Introspection of an access token (see )
---------------------------------------------------------------------------------------

[](#example-7-introspection-of-an-access-token-see-httpstoolsietforghtmlrfc7662)

```
use pzworks\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$data = $oidc->introspectToken('an.access-token.as.given');
if (!$data->active) {
    // the token is no longer usable
}
```

Development Environments
------------------------

[](#development-environments)

In some cases you may need to disable SSL security on on your development systems. Note: This is not recommended on production systems.

```
$oidc->setVerifyHost(false);
$oidc->setVerifyPeer(false);
```

### Todo

[](#todo)

- Dynamic registration does not support registration auth tokens and endpoints

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

[](#contributing)

- All pull requests, once merged, should be added to the changelog.md file.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.2% 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 ~114 days

Recently: every ~83 days

Total

13

Last Release

2349d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.2

0.3.0PHP &gt;=5.4

### Community

Maintainers

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

---

Top Contributors

[![jumbojett](https://avatars.githubusercontent.com/u/410057?v=4)](https://github.com/jumbojett "jumbojett (153 commits)")[![pzworks](https://avatars.githubusercontent.com/u/12241773?v=4)](https://github.com/pzworks "pzworks (22 commits)")[![DeepDiver1975](https://avatars.githubusercontent.com/u/1005065?v=4)](https://github.com/DeepDiver1975 "DeepDiver1975 (14 commits)")[![rasodu](https://avatars.githubusercontent.com/u/13222196?v=4)](https://github.com/rasodu "rasodu (9 commits)")[![radenui](https://avatars.githubusercontent.com/u/9445250?v=4)](https://github.com/radenui "radenui (9 commits)")[![kenguest](https://avatars.githubusercontent.com/u/234118?v=4)](https://github.com/kenguest "kenguest (7 commits)")[![morcs](https://avatars.githubusercontent.com/u/555420?v=4)](https://github.com/morcs "morcs (6 commits)")[![jdreed](https://avatars.githubusercontent.com/u/4193101?v=4)](https://github.com/jdreed "jdreed (5 commits)")[![guss77](https://avatars.githubusercontent.com/u/381782?v=4)](https://github.com/guss77 "guss77 (5 commits)")[![baru](https://avatars.githubusercontent.com/u/688602?v=4)](https://github.com/baru "baru (5 commits)")[![corentingi](https://avatars.githubusercontent.com/u/3458976?v=4)](https://github.com/corentingi "corentingi (4 commits)")[![adambartholomew](https://avatars.githubusercontent.com/u/324503?v=4)](https://github.com/adambartholomew "adambartholomew (3 commits)")[![JTubex](https://avatars.githubusercontent.com/u/5894935?v=4)](https://github.com/JTubex "JTubex (3 commits)")[![lordelph](https://avatars.githubusercontent.com/u/444004?v=4)](https://github.com/lordelph "lordelph (3 commits)")[![n0nag0n](https://avatars.githubusercontent.com/u/2322095?v=4)](https://github.com/n0nag0n "n0nag0n (3 commits)")[![hallgeirlien](https://avatars.githubusercontent.com/u/12511450?v=4)](https://github.com/hallgeirlien "hallgeirlien (2 commits)")[![krisrandall](https://avatars.githubusercontent.com/u/1888888?v=4)](https://github.com/krisrandall "krisrandall (2 commits)")[![benyitzhaki](https://avatars.githubusercontent.com/u/2536651?v=4)](https://github.com/benyitzhaki "benyitzhaki (2 commits)")[![jricher](https://avatars.githubusercontent.com/u/122511?v=4)](https://github.com/jricher "jricher (2 commits)")[![rghose](https://avatars.githubusercontent.com/u/5793339?v=4)](https://github.com/rghose "rghose (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pzworks-openid-connect-php/health.svg)

```
[![Health](https://phpackages.com/badges/pzworks-openid-connect-php/health.svg)](https://phpackages.com/packages/pzworks-openid-connect-php)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M670](/packages/laravel-socialite)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M527](/packages/laravel-passport)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6503.9M9](/packages/aporat-store-receipt-validator)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)

PHPackages © 2026

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