{"id":17215080,"url":"https://github.com/mozmorris/facebookauthenticate-cakephp-authentication-handler","last_synced_at":"2025-04-13T23:16:33.880Z","repository":{"id":1991756,"uuid":"2924357","full_name":"mozmorris/FacebookAuthenticate-CakePhp-Authentication-Handler","owner":"mozmorris","description":"Facebook authentication handler for CakePHP 2.0","archived":false,"fork":false,"pushed_at":"2013-01-12T18:28:04.000Z","size":189,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T23:16:27.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/mozmorris.png","metadata":{"files":{"readme":"README.markdown","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":"2011-12-06T11:47:17.000Z","updated_at":"2023-05-25T10:58:11.000Z","dependencies_parsed_at":"2022-09-21T11:11:27.160Z","dependency_job_id":null,"html_url":"https://github.com/mozmorris/FacebookAuthenticate-CakePhp-Authentication-Handler","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/mozmorris%2FFacebookAuthenticate-CakePhp-Authentication-Handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozmorris%2FFacebookAuthenticate-CakePhp-Authentication-Handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozmorris%2FFacebookAuthenticate-CakePhp-Authentication-Handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozmorris%2FFacebookAuthenticate-CakePhp-Authentication-Handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mozmorris","download_url":"https://codeload.github.com/mozmorris/FacebookAuthenticate-CakePhp-Authentication-Handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794569,"owners_count":21162615,"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-10-15T03:23:09.142Z","updated_at":"2025-04-13T23:16:33.847Z","avatar_url":"https://github.com/mozmorris.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FacebookAuthenticate - CakePhp Facebook Authentication Handler\n* Author:  Moz Morris (moz@earthview.co.uk)\n* version 1.1\n* http://www.earthview.co.uk\n* license: MIT\n\nThe purpose of the Facebook Authentication Handler is to provide Facebook Authentication for your CakePHP 2.0 or later based application. The handler has been built following Cake's recommended approach for building [custom authentication objects](http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html?#creating-custom-authentication-objects \"Authentication \u0026mdash; CakePHP Cookbook v2.0.0 documentation\") for use with the built in AuthComponent.\nThe handler itself is part a *FacebookAuth* plugin, though this is essentially to make the handler easily redistributable with example configuration settings and an example controller detailing a typical use case scenario.\n\nIt should be noted that though this handler stores the access token returned by Facebook, it **does not** currently provide a means to makes calls to the Graph API. It's function is to provide authentication. Of course, you could use the access token and your preferred method to communicate with Facebook.\n\n# Changelog\n\n* 1.0 Sharing it with the world for the very first time.\n* 1.1 Add email \u0026 name fields by default \u0026 ensure handler uses configuration settings\n\n# Installation\n\n## Get the code\n\n### Via Git\n\nFirst clone the repository into a new `app/Plugin/FacebookAuth` directory\n\n    git clone git://github.com/MozMorris/FacebookAuthenticate-CakePhp-Authentication-Handler.git /path/to/your/app/Plugin/FacebookAuth\n\n### Via Composer\n\nAdd a dependency to your `composer.json` file. (Looks like the CakePHP convention is to have the `composer.json` file located under `app/`)\n\n    \"require\": {\n      \"moz-morris/cakephp-facebook-auth\": \"dev-master\"\n    }\n\nThen `composer install` or `composer update`. You might need to add `\"minimum-stability\": \"dev\"` to you `composer.json` file.\n\n\n## Facebook Application \u0026 App Configuration\n\n1. Rename the example configuration *FacebookConfig.ini.example* to **FacebookConfig.ini**. It can be found under app/Plugin/FacebookAuth/Config/\n2. Head on over to the [Facebook Developer App](https://developers.facebook.com/apps) and either setup a new application to get a App ID/API Key \u0026 App Secret, or note down the ones from your existing app. **NOTE: Your 'App Domain' must be the same host as you're accessing your site with to enable Auth.** Otherwise, when you attempt to authenticate, Facebook will return \"API Error Code: 191 | API Error Description: The specified URL is not owned by the application | Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.\"\n3. Update your FacebookConfig.ini with the App ID/API Key \u0026 App Secret.\n4. Load the plugin and it's configuration in your bootstrap file *app/Config/bootstrap.php*\n5. Configure the FacebookAuth handler at runtime\n\nLoading the plugin and configuration (*bootstrap.php*):\n\n    /**\n     * Load custom configuration files using the IniReader class\n     */\n    App::uses('IniReader', 'Configure');\n    Configure::config('default', new IniReader(APP . 'Plugin' . DS . 'FacebookAuth' . DS . 'Config' . DS));\n    Configure::load('FacebookConfig', 'default');\n\n    /**\n     * Load Facebook Plugin\n     */\n    CakePlugin::load('FacebookAuth');\n\nConfiguring the handler at runtime:\n\n    public function beforeFilter()\n    {\n      parent::beforeFilter();\n\n      /**\n       * Configure FacebookAuth handler\n       */\n      $this-\u003eAuth-\u003eauthenticate['FacebookAuth.Facebook']['application'] = array(\n       'id'     =\u003e Configure::read('facebook.app_id'),\n       'secret' =\u003e Configure::read('facebook.app_secret')\n      );\n    }\n\n## Database\n\nAdd `email`, `name`, `facebook_user_id`, `facebook_access_token` fields to your User model. In this example we're adding the fields to the _users_ table which is pretty much the standard for Cake apps using some kind of user authentication. If your app is slightly different, then make the relevant changes.\n\n    ALTER TABLE `users` ADD `email` VARCHAR(255)  NOT NULL  DEFAULT '';\n    ALTER TABLE `users` ADD `name` VARCHAR(255)  NOT NULL  DEFAULT '';\n    ALTER TABLE `users` ADD `facebook_user_id` BIGINT  NULL  DEFAULT NULL;\n    ALTER TABLE `users` ADD `facebook_access_token` VARCHAR(255)  NULL  DEFAULT NULL;\n\n\n# Usage\n\nBasic example:\n\n    public $components = array(\n      'Auth'=\u003e array(\n        'authenticate' =\u003e array(\n          'FacebookAuth.Facebook'\n        )\n      )\n    );\n\nSlightly more interesting:\n\n    public $components = array(\n      'Auth'=\u003e array(\n        'loginAction' =\u003e array(\n          'controller' =\u003e 'users',\n          'action' =\u003e 'login'\n        ),\n        'loginRedirect' =\u003e array(\n          'controller' =\u003e 'users',\n          'action' =\u003e 'my_account'\n        ),\n        'authError' =\u003e 'Did you really think you are allowed to see that?',\n        'authenticate' =\u003e array(\n          'FacebookAuth.Facebook' =\u003e array(\n            'fields' =\u003e array(\n              'username' =\u003e 'email',\n        \t\t\t'password' =\u003e 'password'\n            )\n          )\n        )\n      )\n    );\n\nSee the Cake Book for more ways to configure your [CakePHP AuthComponent](http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html \"Authentication \u0026mdash; CakePHP Cookbook v2.0.0 documentation\").\n\nThere is also an example controller included within the plugin that shows how you could implement the handler.\n\n    app/Plugin/FacebookAuth/Controller/ExampleController.php\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozmorris%2Ffacebookauthenticate-cakephp-authentication-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmozmorris%2Ffacebookauthenticate-cakephp-authentication-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozmorris%2Ffacebookauthenticate-cakephp-authentication-handler/lists"}