Hybridauth 3 - Google Provider - Invalid Credentials

567 views Asked by At

Hy. I have a problem with provider Google with HybridAuth 3.8.0. I have two php pages.

Page Sign-In.php

try
{
  $config= [    
      'callback' => 'https://xxxxxxxxxx/gcallback',
      'keys' => [
          'id' => 'xxxxxxxxxxapps.googleusercontent.com',
          'secret' => 'secret'
        ],
        'scope' => 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile', 
        'authorize_url_parameters' => [
          'approval_prompt' => 'force', 
          'access_type' => 'offline'
        ],        
    ];

    $adapter = new \Hybridauth\Provider\Google($config);
    $adapter->authenticate(); // Redirect to Google   
}
catch(Exception $e)
{
   die($e->getMessage);
}

Page gcallback.php

try
{
$adapter = new \Hybridauth\Provider\Google($config);   
// This line is commented because redirect loop to Google
//$adapter->authenticate();
$userdata= $adapter->getUserProfile();
die(var_dump($userdata));
}
catch(Exception $e)
{
die($e->getMessage());
}

After User Login successfully, callback page show this error:

ERROR: Signed API request to https://www.googleapis.com/oauth2/v3/userinfo has returned an error. HTTP error 401. Raw Provider API response: {"error": "invalid_request", "error_description": "invalid Credentials"}

How can I fix it? In my Google Cloud Platform, my project is in testing mode (oauth consent screen). I have created two test email users.

0

There are 0 answers