PHPackages                             iescarro/codeigniter3-social - 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. iescarro/codeigniter3-social

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

iescarro/codeigniter3-social
============================

Social Authentication for CodeIgniter 3

v0.1.1(7mo ago)013MITPHPPHP &gt;=8.1

Since Oct 6Pushed 7mo agoCompare

[ Source](https://github.com/iescarro/codeigniter3-social)[ Packagist](https://packagist.org/packages/iescarro/codeigniter3-social)[ RSS](/packages/iescarro-codeigniter3-social/feed)WikiDiscussions main Synced 1mo ago

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

[![Logo CodeIgniter3 Social](/art/logo.png)](/art/logo.png)

 [![Total Downloads](https://camo.githubusercontent.com/e61ef8fe7d89a44e5796f88f22403b9782e9c29963cf2d5cdc1d97781397f0ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696573636172726f2f636f646569676e69746572332d736f6369616c)](https://packagist.org/packages/iescarro/codeigniter3-social) [![Latest Stable Version](https://camo.githubusercontent.com/497e3124fd35069658601ee3f1fd8c2c345c812b5ea59b772a9ab6c88ad63ef5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696573636172726f2f636f646569676e69746572332d736f6369616c)](https://packagist.org/packages/iescarro/codeigniter3-social) [![License](https://camo.githubusercontent.com/f0280930ee0fddab175bc6cfc307901efc65c67836ebd3cb6bc402f5c5315a41/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696573636172726f2f636f646569676e69746572332d736f6369616c)](https://packagist.org/packages/iescarro/codeigniter3-social)

CodeIgniter 3 Social Login (OAuth 2.0) Library
==============================================

[](#codeigniter-3-social-login-oauth-20-library)

A simple, minimal library for integrating Social Login (OAuth 2.0) into your CodeIgniter 3 projects. Easily enable login functionality for major platforms like Google, Facebook, and GitHub without managing complex API calls.

✨ Features
----------

[](#-features)

- Multi-Provider Support: Easily configure and use multiple social providers.
- Simple Setup: Follows CodeIgniter 3 conventions (Controller/Library/Config).
- OAuth 2.0 Flow Management: Handles the entire authorization and token exchange process.
- User Data Retrieval: Fetches essential user information (ID, Name, Email) from the provider.
- Customizable Scopes: Request specific user permissions (e.g., email, profile).

⚙️ Requirements
---------------

[](#️-requirements)

- CodeIgniter 3.x
- PHP 5.6 or higher (PHP 7.x recommended)
- cURL PHP extension enabled (necessary for secure API calls)
- Composer (highly recommended for dependency management)

📦 Installation
--------------

[](#-installation)

Option 1: Using Composer (Recommended)

- Navigate to your CodeIgniter project root directory.
- Run the following command:

```
composer require iescarro/codeigniter3-social
```

- Ensure your application/config/config.php file is configured to use Composer's autoloader:

```
$config['composer_autoload'] = TRUE;
```

Option 2: Manual Installation

- Download the repository files.
- Place the Social.php file into your application/libraries/ folder.
- Manually install any third-party dependencies required by the library (check the repository's composer.json for details).

🔑 Configuration
---------------

[](#-configuration)

1. Register OAuth Apps Before use, you must register your application on each provider's developer console (e.g., Google Cloud Console, Meta for Developers, GitHub Developer Settings) to obtain a Client ID and Client Secret.
2. Configure Environment Variables (.env) For security and portability, all credentials must be stored in a .env file in your project root. This version utilizes the APP\_URL variable to ensure consistency when deploying across different environments.

Place the following configuration into your .env file, replacing the placeholder values with the credentials obtained from each provider's developer console.

```
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=${APP_URL}/auth/google/callback

GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GITHUB_REDIRECT_URI=${APP_URL}/auth/github/callback

FB_APP_ID=your-fb-app-id
FB_APP_SECRET=your-fb-app-secret
FB_CALLBACK_URL=${APP_URL}/auth/facebook/callback

```

3. Set Redirect URIs

    Ensure the redirect\_uri defined above is entered exactly into the respective developer console for each provider.

💡 Usage Example
---------------

[](#-usage-example)

You will typically interact with the library from a central Auth Controller.

1. Configure Routes (application/config/routes.php) The callback URLs must be mapped to your controller functions:

```
$route['auth/google/callback'] = 'login/google_callback';
$route['auth/github/callback'] = 'login/github_callback';
```

2. Load the Library Auto-load the library in application/config/autoload.php or load it in your controller's constructor:

```
$this->load->library('social');
```

3. Login Controller (application/controllers/Login.php) This controller handles the initiation (redirect) and the response (callback) for the OAuth flow.

```
