I started coding for registration page with social accounts. I tried facebook its successful working. When i try google sign its showing me this error.
400. That’s an error.
Error: invalid_request
Missing required parameter: scope
Learn more
Request Details
response_type=code
redirect_uri=http://localhost/school/g.php
client_id=80808106457-e2fmm4s2dhqc5eo94nv2l84thjn6hqvl.apps.googleusercontent.com
scope=
access_type=offline
approval_prompt=force
Someone please help me.This is my php code
<?php
session_start();
// Include Google client library
include_once 'src/Google_Client.php';
include_once 'src/auth/Google_OAuth2.php';
/*
* Configuration and setup Google API
*/
$clientId = 'XXXXXXXXXXXXXXXXXXXXXX';
$clientSecret = 'XXXXXXXXXXXXXXXX';
$redirectURL = 'http://localhost/school/g.php';
//Call Google API
$gClient = new Google_Client();
$gClient->setApplicationName('school');
$gClient->setAccessType("offline");
$gClient->setClientId($clientId);
$gClient->setClientSecret($clientSecret);
$gClient->setRedirectUri($redirectURL);
$google_oauthV2 = new Google_OAuth2($gClient);
?>
You must declare the scope you wish to access, for example - the highest privileged scope for Gmail which also allows an offline access is added with:
$gClient->addScope('https://mail.google.com/');
Be wise when choosing the correct scope, the client will see the scope you're trying to access and will decide upon it whether to approve or not (done on user's consent screen).
List of scopes - https://developers.google.com/identity/protocols/googlescopes