phplaravel-5google-authenticationhybridauth

Google authentication in laravel application - hybrid auth error


I am trying to add google authentication in my laravel application using hybrid auth.

Google auth configuration:

<?php

return array(

    "base_url" => "https://mywebsite.com/gauth/auth",
    "providers" => array(

        "Google" => array(

            "enabled" => true,
            "keys" => array(
                "id" => "myid.apps.googleusercontent.com",
                "secret" => "mysecret"
            ),
            "scope" => "https://www.googleapis.com/auth/userinfo.email "

        )

    )

);

The authentication worked fine in the http website. But when I added SSL/https to the site it is not working and I am getting the following error:

Exception in Auth.php line 169:
User profile request failed! Google returned an error: exception 'Exception' with message 'The Authorization Service has return: invalid_request' in /project/httpdocs/vendor/hybridauth/hybridauth/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php:84

What is the issue causing this error?


Solution

  • I think the error was due to the PHP version. The PHP version was higher than recommended by the Hybrid Auth.

    Used the Google PHP library and worked fine. https://developers.google.com/api-client-library/php/auth/web-app