Closed kh176 closed 8 years ago
Hi, are you sure you set up your app correctly with the correct testing domain?
Yes i have the same probleme with Facebook and google and when I inspect the request i saw the response of google and Facebook but the application say You are not authorized to access that location. Look like the acion who get the response are not allowed I don't know...
Oh okay, then it's a problem with your permissions.php set up. I had the same problem. The solution is explained here:
https://github.com/CakeDC/users/issues/323#issuecomment-199241475
But what is the action of social login that i have to allow
It is not the action of social log in you need to allow, it is all the pages in your applications that are not allowed to be viewed once you're logged in. The log in actually works fine, but the reason you get the message is that your permissions are not set up properly, and thus you're not allowed to view any page.
No i can access to profile page and Reset password ...
If i use Simple login
@kh176 could you please post your plugin configuration here?
`$config = [
'Users' => [
//Table used to manage users
'table' => 'CakeDC/Users.Users',
//configure Auth component
'auth' => true,
//Password Hasher
'passwordHasher' => '\Cake\Auth\DefaultPasswordHasher',
//token expiration, 1 hour
'Token' => ['expiration' => 3600],
'Email' => [
//determines if the user should include email
'required' => true,
//determines if registration workflow includes email validation
'validate' => true,
],
'Registration' => [
//determines if the register is enabled
'active' => true,
//determines if the reCaptcha is enabled for registration
'reCaptcha' => true,
],
'Tos' => [
//determines if the user should include tos accepted
'required' => true,
],
'Social' => [
//enable social login
'login' => true,
],
'Profile' => [
//Allow view other users profiles
'viewOthers' => true,
'route' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'profile'],
],
'Key' => [
'Session' => [
//session key to store the social auth data
'social' => 'Users.social',
//userId key used in reset password workflow
'resetPasswordUserId' => 'Users.resetPasswordUserId',
],
//form key to store the social auth data
'Form' => [
'social' => 'social'
],
'Data' => [
//data key to store the users email
'email' => 'email',
//data key to store email coming from social networks
'socialEmail' => 'info.email',
//data key to check if the remember me option is enabled
'rememberMe' => 'remember_me',
],
],
//Avatar placeholder
'Avatar' => ['placeholder' => 'CakeDC/Users.avatar_placeholder.png'],
'RememberMe' => [
//configure Remember Me component
'active' => true,
'Cookie' => [
'name' => 'remember_me',
'Config' => [
'expires' => '1 month',
'httpOnly' => true,
]
]
],
],
//default configuration used to auto-load the Auth Component, override to change the way Auth works
'Auth' => [
'loginAction' => [
'plugin' => 'CakeDC/Users',
'controller' => 'Users',
'action' => 'login',
'prefix' => false
],
'authenticate' => [
'all' => [
'scope' => ['active' => 1]
],
'CakeDC/Users.ApiKey',
'CakeDC/Users.RememberMe',
'Form',
],
'authorize' => [
'CakeDC/Users.Superuser',
'CakeDC/Users.SimpleRbac',
],
],
'OAuth' => [
'path' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialLogin', 'prefix' => false],
'providers' => [
'facebook' => [
'className' => 'League\OAuth2\Client\Provider\Facebook',
'options' => [
'graphApiVersion' => 'v2.5',
'redirectUri' => Router::url('/auth/facebook', true)
]
],
'twitter' => [
'options' => [
'redirectUri' => Router::url('/auth/twitter', true)
]
],
'linkedIn' => [
'className' => 'League\OAuth2\Client\Provider\LinkedIn',
'options' => [
'redirectUri' => Router::url('/auth/linkedIn', true)
]
],
'instagram' => [
'className' => 'League\OAuth2\Client\Provider\Instagram',
'options' => [
'redirectUri' => Router::url('/auth/instagram', true)
]
],
'google' => [
'className' => 'League\OAuth2\Client\Provider\Google',
'options' => [
'userFields' => ['url', 'aboutMe'],
'redirectUri' => Router::url('/auth/google', true)
]
],
],
]
];
return $config;
`
This is my permission file :
`
return [
'Users.SimpleRbac.permissions' => [
[
'role' => '*',
'plugin' => 'CakeDC/Users',
'controller' => '*',
'action' => '*',
],
[
'role' => 'user',
'plugin' => 'CakeDC/Users',
'controller' => 'Users',
'action' => ['register', 'edit', 'view'],
],
[
'role' => 'user',
'plugin' => 'CakeDC/Users',
'controller' => 'Users',
'action' => '*',
'allowed' => true,
],
[
'role' => ['user'],
'controller' => ['Pages'],
'action' => ['other', 'display'],
'allowed' => true,
],
]];`
What is the action which trait the respnse of Google and Facebook ? And why Twitter has his own action ? I am blocked please help me
Now twiiter after login redirect me to : http://projettest.com/users/users/social-email with the message : Not Found Cake\Network\Exception\NotFoundException and when i debug the user in twitterlogin i saw the email=null why ?
Hi @kh176 What is the action which trait the respnse of Google and Facebook ?
And why Twitter has his own action ?
Now twiiter after login redirect me to : http://projettest.com/users/users/social-email
About your configuration, I assume you already configured your bootstrap with the clientId and secret, what version of the plugin are you using btw?
closed as duplicated #338
The last one
Can you please help me
Sure, let's continue debugging...
Could you paste here the bootstrap.php related code where you load the plugin please?
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 0.10.8
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Configure paths required to find CakePHP + general filepath
* constants
*/
require __DIR__ . '/paths.php';
// Use composer to load the autoloader.
require ROOT . DS . 'vendor' . DS . 'autoload.php';
/**
* Bootstrap CakePHP.
*
* Does the various bits of setup that CakePHP needs to do.
* This includes:
*
* - Registering the CakePHP autoloader.
* - Setting the default application paths.
*/
require CORE_PATH . 'config' . DS . 'bootstrap.php';
// You can remove this if you are confident that your PHP version is sufficient.
if (version_compare(PHP_VERSION, '5.5.9') < 0) {
trigger_error('You PHP version must be equal or higher than 5.5.9 to use CakePHP.', E_USER_ERROR);
}
// You can remove this if you are confident you have intl installed.
if (!extension_loaded('intl')) {
trigger_error('You must enable the intl extension to use CakePHP.', E_USER_ERROR);
}
// You can remove this if you are confident you have mbstring installed.
if (!extension_loaded('mbstring')) {
trigger_error('You must enable the mbstring extension to use CakePHP.', E_USER_ERROR);
}
use Cake\Cache\Cache;
use Cake\Console\ConsoleErrorHandler;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\Plugin;
use Cake\Database\Type;
use Cake\Datasource\ConnectionManager;
use Cake\Error\ErrorHandler;
use Cake\Log\Log;
use Cake\Mailer\Email;
use Cake\Network\Request;
use Cake\Routing\DispatcherFactory;
use Cake\Utility\Inflector;
use Cake\Utility\Security;
/**
* Read configuration file and inject configuration into various
* CakePHP classes.
*
* By default there is only one configuration file. It is often a good
* idea to create multiple configuration files, and separate the configuration
* that changes from configuration that does not. This makes deployment simpler.
*/
try {
Configure::config('default', new PhpConfig());
Configure::load('app', 'default', false);
} catch (\Exception $e) {
exit($e->getMessage() . "\n");
}
// Load an environment local configuration file.
// You can use a file like app_local.php to provide local overrides to your
// shared configuration.
//Configure::load('app_local', 'default');
// When debug = false the metadata cache should last
// for a very very long time, as we don't want
// to refresh the cache while users are doing requests.
if (!Configure::read('debug')) {
Configure::write('Cache._cake_model_.duration', '+1 years');
Configure::write('Cache._cake_core_.duration', '+1 years');
}
/**
* Set server timezone to UTC. You can change it to another timezone of your
* choice but using UTC makes time calculations / conversions easier.
*/
date_default_timezone_set('UTC');
/**
* Configure the mbstring extension to use the correct encoding.
*/
mb_internal_encoding(Configure::read('App.encoding'));
/**
* Set the default locale. This controls how dates, number and currency is
* formatted and sets the default language to use for translations.
*/
ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
/**
* Register application error and exception handlers.
*/
$isCli = PHP_SAPI === 'cli';
if ($isCli) {
(new ConsoleErrorHandler(Configure::read('Error')))->register();
} else {
(new ErrorHandler(Configure::read('Error')))->register();
}
// Include the CLI bootstrap overrides.
if ($isCli) {
require __DIR__ . '/bootstrap_cli.php';
}
/**
* Set the full base URL.
* This URL is used as the base of all absolute links.
*
* If you define fullBaseUrl in your config file you can remove this.
*/
if (!Configure::read('App.fullBaseUrl')) {
$s = null;
if (env('HTTPS')) {
$s = 's';
}
$httpHost = env('HTTP_HOST');
if (isset($httpHost)) {
Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
}
unset($httpHost, $s);
}
Cache::config(Configure::consume('Cache'));
ConnectionManager::config(Configure::consume('Datasources'));
Email::configTransport(Configure::consume('EmailTransport'));
Email::config(Configure::consume('Email'));
Log::config(Configure::consume('Log'));
Security::salt(Configure::consume('Security.salt'));
/**
* The default crypto extension in 3.0 is OpenSSL.
* If you are migrating from 2.x uncomment this code to
* use a more compatible Mcrypt based implementation
*/
//Security::engine(new \Cake\Utility\Crypto\Mcrypt());
/**
* Setup detectors for mobile and tablet.
*/
Request::addDetector('mobile', function ($request) {
$detector = new \Detection\MobileDetect();
return $detector->isMobile();
});
Request::addDetector('tablet', function ($request) {
$detector = new \Detection\MobileDetect();
return $detector->isTablet();
});
/**
* Custom Inflector rules, can be set to correctly pluralize or singularize
* table, model, controller names or whatever other string is passed to the
* inflection functions.
*
* Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
* Inflector::rules('irregular', ['red' => 'redlings']);
* Inflector::rules('uninflected', ['dontinflectme']);
* Inflector::rules('transliteration', ['/å/' => 'aa']);
*/
/**
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
* advanced ways of loading plugins
*
* Plugin::loadAll(); // Loads all plugins at once
* Plugin::load('Migrations'); //Loads a single plugin named Migrations
*
*/
Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
Configure::write('Users.Social.login', true); //to enable social login
Configure::write('Auth.authenticate.Form.fields.username', 'email');
Configure::write('OAuth.providers.facebook.options.clientId', '866098280167491');
Configure::write('OAuth.providers.facebook.options.clientSecret', 'efac6c33e4274bcd5c6e2728b1ace18d');
Configure::write('OAuth.providers.google.options.clientId', '772409145076-birdmh5a3t48b8mg9knq0lonup6aeomk.apps.googleusercontent.com');
Configure::write('OAuth.providers.google.options.clientSecret', 'bMsN60f_CK0pcJsO1bq3O6sd');
Configure::write('OAuth.providers.twitter.options.clientId', 'VTMSqqqB1zj3LJf5kSybpc73l');
Configure::write('OAuth.providers.twitter.options.clientSecret', 'uxF8nUt7EDGrQrtLdriHMgzFQplSpHUEox2byYPIHdDK34CfNq');
configure::write('OAuth.providers.twitter.options.redirectUri','http://projettest.com/auth/twitter');
Plugin::load('Migrations');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
* Connect middleware/dispatcher filters.
*/
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
/**
* Enable default locale format parsing.
* This is needed for matching the auto-localized string output of Time() class when parsing dates.
*
* Also enable immutable time objects in the ORM.
*/
Type::build('time')
->useImmutable()
->useLocaleParser();
Type::build('date')
->useImmutable()
->useLocaleParser();
Type::build('datetime')
->useImmutable()
->useLocaleParser();
This is Plugin Bootstrap.php :
<?php
/**
* Copyright 2010 - 2015, Cake Development Corporation (+1 702 425 5085) (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (+1 702 425 5085) (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
use Cake\Core\Configure;
use Cake\Log\Log;
use Cake\Core\Exception\MissingPluginException;
use Cake\Core\Plugin;
use Cake\Event\EventManager;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
Configure::load('CakeDC/Users.users');
Configure::write('Auth.authenticate.Form.fields.username', 'email');
collection((array)Configure::read('Users.config'))->each(function ($file) {
Configure::load($file);
});
if (Configure::check('Users.auth')) {
Configure::write('Auth.authenticate.all.userModel', Configure::read('Users.table'));
}
if (Configure::read('Users.Social.login') && php_sapi_name() != 'cli') {
try {
EventManager::instance()->on(\CakeDC\Users\Controller\Component\UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, [new \CakeDC\Users\Controller\UsersController(), 'failedSocialLoginListener']);
} catch (MissingPluginException $e) {
Log::error($e->getMessage());
}
}
$oauthPath = Configure::read('OAuth.path');
if (is_array($oauthPath)) {
Router::scope('/auth', function ($routes) use ($oauthPath) {
$routes->connect(
'/:provider',
$oauthPath,
['provider' => implode('|', array_keys(Configure::read('OAuth.providers')))]
);
});
}
This what i have as result when i click on log in with Google or Facebook : screenshot : http://img15.hostingpics.net/pics/569392Sanstitre.png
Hi,
The same problem here. I've tried with clean Cake Install, public domain, using the google sign-in and following step by step the instructions again and again... And no way... I get the You are not authorized to access that location.
And it doesn't appear any new user in the tables social_accounts or users.
UPDATE: In my case I setup the facebook login and it works perfectly but not with google. For the ones trying to use the facebook login I let you a link to the Jorge Gonzalez tutorial to setup you login with facebook, is more straightforward than the github docs: http://www.cakedc.com/jorge_gonzalez/2015/10/02/cakephp_facebook_login_using_cakedc_users_plugin Also this tutorial, about the old version but good anyway because you can see some trick with the profiles URL and etc: http://zaidisoft.com/cakedc-users-plugin-install-guide-cakephp-application/
I hope it will help a bit ;)
Thanks in advance, David
after much troubleshooting of the same original issue, for me the solution was that I was missing a CA Root Certificates file reference in php.ini in my WAMP installation (having recenlty installed a newer version of WAMP in Windows.) In php.ini, I needed to add
curl.cainfo = "c:/wamp/cacert.pem"
pointing to my root CA Certificate bundle (I got a new copy of the bundle at https://curl.haxx.se/ca/cacert.pem )
in the [curl] section, because not having this caused an error when facebook was connecting back to my app. If you've got multiple versions of PHP like I do, be sure you make the edit to the php.ini for each version. I believe this is only an issue in Windows (I think other OS's maintain their own built-in list of Certificate Authorities.)
Hope this is helpful to someone else.
Hi when I try to log in with Facebook.. It say : You are not authorized to access that location. I have configured Virtuaalhost.. And the url guived to Facebook is : http://projettest.com/auth/facebook
Please Help.