Question: Social Auth Not Working

Social Auth Not Working

Hi, i am facing issue with social auth login for Facebook and Google. As per documentation, i have added these redirect url in both facebook and google app. https://larebco.com/social_aut

MM

MOHAMMED MAHMOOD

Asked
Hi, i am facing issue with social auth login for Facebook and Google. As per documentation, i have added these redirect url in both facebook and google app.

https://larebco.com/social_auth/login/Facebook https://larebco.com/social_auth/login/Google
Also enabled in hybridauthlib.php file.

But when i execute the social login, then Google gives me “Error 400: redirect_uri_mismatch” error and shows on screen that redirect url should be like this: redirect_uri: https://larebco.com/?hauth_done=Google

On facebook login, it gives below error:

“URL blocked: This redirect failed because the redirect URI is not white-listed in the app’s client OAuth settings. Make sure that the client and web OAuth logins are on and add all your app domains as valid OAuth redirect URIs.”

I also tried with these these redirect url in both social app:

https://larebco.com/social_auth/endpoint/?hauth_done=Facebook https://larebco.com/social_auth/endpoint/?hauth_done=Google
But getting same issue. Here is my shop website link: https://larebco.com/

Please advice me on this asap.
  • MS

    Mian Saleem

    Answered
    Hello,

    The urls are mentioned on the shop settings page. You can enable the `debug_mode` in hybridauthlib.php and then try to login and check the error in `app/logs/hybridauth.php`

    Thank you
  • MM

    MOHAMMED MAHMOOD

    Answered
    Please look at this issue asap. Thanks
  • MS

    Mian Saleem

    Answered
    Hello,

    I can see the callback url is different then those mentioned in the settings. I am not sure ehat causing this. I will check this on Tuesday.

    For now, I can't think of anything else than `callback` setting in your hybridauthlib.php config file. Please let me know what the value of callback.

    Thank you
  • MM

    MOHAMMED MAHMOOD

    Answered
    In config hybridauthlib.php file, no callback url set. Here is the setting in this config file:

    'Hauth_base_url' => 'social_auth/endpoint',

    'providers' => [
    'Google' => [
    'enabled' => true,
    'keys' => ['id' => '422294827540-**********************.apps.googleusercontent.com', 'secret' => 'GOCSPX-SuuIjs************EHorRm3j'],
    ],

    'Facebook' => [
    'enabled' => true,
    'keys' => ['id' => '446**********16', 'secret' => '76fce6**************1ceb8e'],
    'scope' => 'email, public_profile, user_birthday',
    ],

    These two redirect urls used in both Facebook and Google social App settings:

    https://larebco.com/social_auth/login/Facebook
    https://larebco.com/social_auth/login/Google
  • MM

    MOHAMMED MAHMOOD

    Answered
    Can you please tell me what should be the config file look like and What urls need to use in Facebook/Google social app settings?
  • MS

    Mian Saleem

    Answered
    Hello,

    Here is the correcy config file

    ```php
    <?php
    defined('BASEPATH') or exit('No direct script access allowed');

    /* ----------------------------------------------------------------------------
    /* HybridAuth Guide: http://hybridauth.github.io/hybridauth/userguide.html
    /* ------------------------------------------------------------------------- */

    $config = [
    // For godady Shared Hosting Server uncomment the line below
    // Please update the callback url too
    'callback' => 'social_auth/login',
    'Hauth_base_url' => 'social_auth/endpoint',

    // Please comment this if you have uncommented the above
    // 'Hauth_base_url' => 'social_auth/endpoint',

    'providers' => [
    'Google' => [
    'enabled' => false,
    'keys' => ['id' => '', 'secret' => ''],
    ],

    'Facebook' => [
    'enabled' => false,
    'keys' => ['id' => '', 'secret' => ''],
    'scope' => 'email, public_profile',
    ],

    'Twitter' => [
    'enabled' => false,
    'keys' => ['key' => '', 'secret' => ''],
    ],

    'Yahoo' => [
    'enabled' => false,
    'keys' => ['id' => '', 'secret' => ''],
    ],

    'Live' => [
    'enabled' => false,
    'keys' => ['id' => '', 'secret' => ''],
    ],

    'MySpace' => [
    'enabled' => false,
    'keys' => ['key' => '', 'secret' => ''],
    ],

    'OpenID' => [
    'enabled' => false,
    ],

    'LinkedIn' => [
    'enabled' => false,
    'keys' => ['key' => '', 'secret' => ''],
    ],

    'Foursquare' => [
    'enabled' => false,
    'keys' => ['id' => '', 'secret' => ''],
    ],

    'AOL' => [
    'enabled' => false,
    ],
    ],

    'debug_mode' => false,

    'debug_file' => APPPATH . 'logs/hybridauth.php',
    ];

    ```

    I think it was due to config , please try the above config.

    Thank you
  • MS

    Mian Saleem

    Answered
    The urls are mentioned on the shiop settings. Please let me know if those are not. Thanks
  • MM

    MOHAMMED MAHMOOD

    Answered
    Yes, these URLs are mentioned in Shop Setting:

    https://larebco.com/social_auth/login/Google
    https://larebco.com/social_auth/login/Facebook.

    I have updated config hybridauthlib.php file with your as you mentioned above. Still it is not working, same authrize error showing.

    In google login, its again and again ask to login with google account. Same login screen showing again an again. Also showing me that redirect URL should be like that: https://larebco.com/social_auth/login?hauth_done=Facebook

    I have used this also, but nothing happened.
  • MM

    MOHAMMED MAHMOOD

    Answered
    Hi, issue is fixed now. It was becuase of htaccess code. Thanks for support
  • MS

    Mian Saleem

    Answered
    I am glad to know and thank you for updating
  • Login to Reply