PHPackages                             agungsugiarto/codeigniter4-socialite - 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. agungsugiarto/codeigniter4-socialite

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

agungsugiarto/codeigniter4-socialite
====================================

Forked from Laravel Socialite wrapper around OAuth 1 &amp; OAuth 2 libraries.

v5.0.0(4y ago)63844MITPHPPHP ^7.2|^8.0

Since Feb 16Pushed 4y agoCompare

[ Source](https://github.com/agungsugiarto/codeigniter4-socialite)[ Packagist](https://packagist.org/packages/agungsugiarto/codeigniter4-socialite)[ RSS](/packages/agungsugiarto-codeigniter4-socialite/feed)WikiDiscussions 5.x Synced today

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

- [About](#about)
- [Introduction](#introduction)
- [Installation](#installation)
- [Configuration](#configuration)
- [Authentication](#authentication)
    - [Routing](#routing)
    - [Optional Parameters](#optional-parameters)
    - [Access Scopes](#access-scopes)
    - [Retrieving User Details](#retrieving-user-details)
- [Contributing](#contributing)
- [License](#license)

About
-----

[](#about)

CodeIgniter4 Socialite is Forked from [Laravel Socialite](https://github.com/laravel/socialite) wrapper around OAuth 1 &amp; OAuth 2 libraries for working with codeigniter4 compatibility.

Introduction
------------

[](#introduction)

CodeIgniter4 Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Google, LinkedIn, GitHub, GitLab and Bitbucket. It handles almost all of the boilerplate social authentication code you are dreading writing.

Installation
------------

[](#installation)

To get started with Socialite, use the Composer package manager to add the package to your project's dependencies:

```
composer require agungsugiarto/codeigniter4-socialite
```

Configuration
-------------

[](#configuration)

Copy the config file from `vendor/agungsugiarto/codeigniter4-socialite/src/Config/Socialite.php` to config folder of your codeigniter4 application change the namespace to `Config` and change class extends from `BaseConfig` to `\Fluent\Socialite\Config\Socialite`

Before using Socialite, you will need to add credentials for the OAuth providers your application utilizes. These credentials should be placed in your application's `app/Config/Socialite.php` configuration file, and should use the key `facebook`, `linkedin`, `google`, `github`, `gitlab`, or `bitbucket`, depending on the providers your application requires:

```
/**
 * {@inheritdoc}
 */
public $services = [
    // ..
    'github' => [
        'client_id'     => '',
        'client_secret' => '',
        'redirect'      => '',
    ],
];
```

> If the `redirect` option contains a relative path, it will automatically be resolved to a fully qualified URL.

Authentication
--------------

[](#authentication)

### Routing

[](#routing)

To authenticate users using an OAuth provider, you will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the callback from the provider after authentication. The example controller below demonstrates the implementation of both routes:

```
use Fluent\Socialite\Facades\Socialite;

$routes->get('auth/redirect', function () {
    return Socialite::driver('github')->redirect();
});

$routes->get('auth/callback', function () {
    $user = Socialite::driver('github')->user();
    // $user->token
});
```

The `redirect` method provided by the `Socialite` facade takes care of redirecting the user to the OAuth provider, while the `user` method will read the incoming request and retrieve the user's information from the provider after they are authenticated.

### Optional Parameters

[](#optional-parameters)

A number of OAuth providers support optional parameters in the redirect request. To include any optional parameters in the request, call the `with` method with an associative array:

```
use Fluent\Socialite\Facades\Socialite;

return Socialite::driver('google')
    ->with(['hd' => 'example.com'])
    ->redirect();
```

> When using the `with` method, be careful not to pass any reserved keywords such as `state` or `response_type`.

### Access Scopes

[](#access-scopes)

Before redirecting the user, you may also add additional "scopes" to the authentication request using the `scopes` method. This method will merge all existing scopes with the scopes that you supply:

```
use Fluent\Socialite\Facades\Socialite;

return Socialite::driver('github')
    ->scopes(['read:user', 'public_repo'])
    ->redirect();
```

You can overwrite all existing scopes on the authentication request using the `setScopes` method:

```
use Fluent\Socialite\Facades\Socialite;

return Socialite::driver('github')
    ->setScopes(['read:user', 'public_repo'])
    ->redirect();
```

Retrieving User Details
-----------------------

[](#retrieving-user-details)

After the user is redirected back to your authentication callback route, you may retrieve the user's details using Socialite's `user` method. The user object returned by the `user` method provides a variety of properties and methods you may use to store information about the user in your own database. Different properties and methods may be available depending on whether the OAuth provider you are authenticating with supports OAuth 1.0 or OAuth 2.0:

```
$routes->get('/auth/callback', function () {
    $user = Socialite::driver('github')->user();

    // OAuth 2.0 providers...
    $token = $user->token;
    $refreshToken = $user->refreshToken;
    $expiresIn = $user->expiresIn;

    // All providers...
    $user->getId();
    $user->getNickname();
    $user->getName();
    $user->getEmail();
    $user->getAvatar();
});
```

#### Retrieving User Details From A Token (OAuth2)

[](#retrieving-user-details-from-a-token-oauth2)

If you already have a valid access token for a user, you can retrieve their details using Socialite's `userFromToken` method:

```
use Fluent\Socialite\Facades\Socialite;

$user = Socialite::driver('github')->userFromToken($token);
```

#### Stateless Authentication

[](#stateless-authentication)

The `stateless` method may be used to disable session state verification. This is useful when adding social authentication to an API:

```
use Fluent\Socialite\Facades\Socialite;

return Socialite::driver('google')->stateless()->user();
```

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

[](#contributing)

Thank you for considering contributing to Socialite!.

License
-------

[](#license)

CodeIgniter4 Socialite is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

32

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Total

2

Last Release

1471d ago

### Community

Maintainers

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

---

Top Contributors

[![taylorotwell](https://avatars.githubusercontent.com/u/463230?v=4)](https://github.com/taylorotwell "taylorotwell (295 commits)")[![driesvints](https://avatars.githubusercontent.com/u/594614?v=4)](https://github.com/driesvints "driesvints (135 commits)")[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (40 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (16 commits)")[![adamgoose](https://avatars.githubusercontent.com/u/611068?v=4)](https://github.com/adamgoose "adamgoose (11 commits)")[![777genius](https://avatars.githubusercontent.com/u/13103045?v=4)](https://github.com/777genius "777genius (10 commits)")[![agungsugiarto](https://avatars.githubusercontent.com/u/10989147?v=4)](https://github.com/agungsugiarto "agungsugiarto (9 commits)")[![georgecoca](https://avatars.githubusercontent.com/u/6689915?v=4)](https://github.com/georgecoca "georgecoca (8 commits)")[![aaronpk](https://avatars.githubusercontent.com/u/113001?v=4)](https://github.com/aaronpk "aaronpk (7 commits)")[![CupOfTea696](https://avatars.githubusercontent.com/u/7327050?v=4)](https://github.com/CupOfTea696 "CupOfTea696 (6 commits)")[![isaackearl](https://avatars.githubusercontent.com/u/9354830?v=4)](https://github.com/isaackearl "isaackearl (5 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (5 commits)")[![SammyK](https://avatars.githubusercontent.com/u/578780?v=4)](https://github.com/SammyK "SammyK (5 commits)")[![teertz](https://avatars.githubusercontent.com/u/9487778?v=4)](https://github.com/teertz "teertz (4 commits)")[![BostjanOb](https://avatars.githubusercontent.com/u/650818?v=4)](https://github.com/BostjanOb "BostjanOb (4 commits)")[![browner12](https://avatars.githubusercontent.com/u/5232313?v=4)](https://github.com/browner12 "browner12 (4 commits)")[![Max13](https://avatars.githubusercontent.com/u/531249?v=4)](https://github.com/Max13 "Max13 (4 commits)")[![ntzm](https://avatars.githubusercontent.com/u/3888578?v=4)](https://github.com/ntzm "ntzm (4 commits)")[![joecohens](https://avatars.githubusercontent.com/u/1803556?v=4)](https://github.com/joecohens "joecohens (3 commits)")[![KerryJones](https://avatars.githubusercontent.com/u/2685411?v=4)](https://github.com/KerryJones "KerryJones (3 commits)")

---

Tags

codeigniter4oauth2oauth2-clientoauthcodeigniter4ouath2-client

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/agungsugiarto-codeigniter4-socialite/health.svg)

```
[![Health](https://phpackages.com/badges/agungsugiarto-codeigniter4-socialite/health.svg)](https://phpackages.com/packages/agungsugiarto-codeigniter4-socialite)
```

###  Alternatives

[league/oauth2-client

OAuth 2.0 Client Library

3.8k115.1M1.0k](/packages/league-oauth2-client)[league/oauth1-client

OAuth 1.0 Client Library

99895.6M95](/packages/league-oauth1-client)[overtrue/socialite

A collection of OAuth 2 packages.

1.4k5.4M78](/packages/overtrue-socialite)[basvandorst/stravaphp

Strava V3 API PHP client with OAuth authentication

193188.1k2](/packages/basvandorst-stravaphp)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

119209.9k1](/packages/ellaisys-aws-cognito)[agungsugiarto/boilerplate

CodeIgniter4 Boilerplate based on AdminLTE 3 with user management, roles, permissions, ...

1637.6k](/packages/agungsugiarto-boilerplate)

PHPackages © 2026

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