{"id":13560101,"url":"https://github.com/dgeorgiev/facebook-ion-auth","last_synced_at":"2025-04-03T15:31:36.505Z","repository":{"id":7295790,"uuid":"8611817","full_name":"dgeorgiev/facebook-ion-auth","owner":"dgeorgiev","description":"facebook login working with ion_auth (codeigniter)","archived":false,"fork":false,"pushed_at":"2017-09-30T08:27:50.000Z","size":8,"stargazers_count":25,"open_issues_count":2,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-28T05:53:56.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgeorgiev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-06T19:56:12.000Z","updated_at":"2024-03-04T15:47:55.000Z","dependencies_parsed_at":"2022-07-21T14:19:41.640Z","dependency_job_id":null,"html_url":"https://github.com/dgeorgiev/facebook-ion-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeorgiev%2Ffacebook-ion-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeorgiev%2Ffacebook-ion-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeorgiev%2Ffacebook-ion-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeorgiev%2Ffacebook-ion-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgeorgiev","download_url":"https://codeload.github.com/dgeorgiev/facebook-ion-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247027955,"owners_count":20871627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:00:37.582Z","updated_at":"2025-04-03T15:31:31.464Z","avatar_url":"https://github.com/dgeorgiev.png","language":"PHP","funding_links":[],"categories":["Libraries","Authentication and Authorization"],"sub_categories":[],"readme":"facebook-ion-auth\n=================\n\nFacebook login working with [CodeIgniter Ion Auth](http://benedmunds.com/ion_auth/)\n\n## Requirement\n\n- [CodeIgniter Ion Auth](http://benedmunds.com/ion_auth/)\n\n## Installation\n\n- Copy `config/facebook_ion_auth.php` to `application/config/facebook_ion_auth.php`.\n- Copy `libraries/Facebook_ion_auth.php` to `application/libraries/Facebook_ion_auth.php`.\n- Configure your Facebook API settings in `application/config/facebook_ion_auth.php` for\n    - `app_id` - Your app id\n    - `app_scret` - Your app secret key\n    - `scope` - custom permissions check - http://developers.facebook.com/docs/reference/login/#permissions\n    - `fields` - fields to retrieve from Facebook; if set to `''`, default is `id,first_name,last_name`; See https://developers.facebook.com/docs/graph-api/reference/user\n    - `redirect_uri` - url to redirect back from facebook. If set to `''`, `site_url('')` will be used\n\n## Example Usage\n\nAssuming that you have installed [CodeIgniter Ion Auth](http://benedmunds.com/ion_auth/), add this in `application/config/autoload.php`.\n\n    $autoload['libraries'] = array('ion_auth', 'Facebook_ion_auth');\n\nCreate `application/core/MY_AuthController.php` and put this code into the file\n\n    \u003c?php\n    if ( ! defined('BASEPATH')) exit('No direct script access allowed');\n\n    /**\n     * AuthController\n     */\n    class MY_AuthController extends CI_Controller\n    {\n        public function __construct()\n        {\n            parent::__construct();\n\n            $this-\u003eload-\u003econfig('ion_auth', true);\n\n            if (uri_string() != 'auth/login') {\n                $this-\u003e_is_login();\n            }\n        }\n\n        private function _is_login()\n        {\n            if (!$this-\u003eion_auth-\u003elogged_in()) {\n                redirect('auth/login');\n            }\n        }\n    }\n\nTo auto-load all files in `application/core/`, add this code in `application/config/config.php`.\n\n    /**\n    | -------------------------------------------------------------------\n    |  Native Auto-load\n    | -------------------------------------------------------------------\n    |\n    | Nothing to do with config/autoload.php, this allows PHP autoload to work\n    | for base controllers and some third-party libraries.\n    |\n    */\n    function __autoload($class)\n    {\n        if(strpos($class, 'CI_') !== 0) {\n            require(APPPATH . 'core/'. $class . '.php');\n        }\n    }\n\nExtends the default controller `application/controllers/Welcome.php` to `MY_AuthController.php` for authentication check.\n\n    class Welcome extends MY_AuthController {\n        // ....\n    }\n\nCreate a new controller file `application/controllers/Facebook_login.php` with the following code:\n\n    \u003c?php\n    defined('BASEPATH') OR exit('No direct script access allowed');\n\n    class Facebook_login extends CI_Controller\n    {\n        /**\n         * Index Page for this controller.\n         * You will be redirected to the facebook login page\n         */\n        function index()\n        {\n            $this-\u003efacebook_ion_auth-\u003elogin();\n        }\n\n        /**\n         * Controller that is redirected back from facebook after login\n         */\n        public function action()\n        {\n            $code = $this-\u003einput-\u003eget('code');\n            if ($code) {\n                $this-\u003efacebook_ion_auth-\u003elogin();\n                redirect('/');\n            } else {\n                redirect('auth/login');\n            }\n        }\n    }\n\nIn `application/views/auth/login.php`, add \"Login with Facebook\" button using the Facebook_login controller created above.\n\n    \u003ca href=\"\u003c?php echo site_url('facebook_login'); ?\u003e\"\u003eLogin with Facebook\u003c/a\u003e\n\nUpdate `application/config/facebook_ion_auth.php` for `redirect_uri`.\n\n    $config['redirect_uri'] = site_url('facebook_login/action'); // url to redirect back from facebook.\n\nThen, when you access your application in the browser, you will see the login form with facebook login button.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgeorgiev%2Ffacebook-ion-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgeorgiev%2Ffacebook-ion-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgeorgiev%2Ffacebook-ion-auth/lists"}