2017-04-23 88 views
0

我開始使用社交帳戶編碼註冊頁面。 我試過Facebook的成功工作。 當我嘗試谷歌簽署其顯示我這個錯誤。缺少必需的參數:範圍(使用PHP中的Google SIgn)

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 

有人請幫助me.This是我的PHP代碼

<?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); 
?> 
+0

您是否閱讀過錯誤信息? *缺少必要的參數:**範圍*** – Pharaoh

+0

@Pharaoh我得到解決我的錯誤 – Karthik

回答

0

您必須聲明你要訪問的範圍,例如 - Gmail的最高特權的範圍也允許離線訪問添加了:

$gClient->addScope('https://mail.google.com/'); 

是明智的選擇正確的範圍時,客戶會看到你要訪問並在其將決定是否批准或者不批准的範圍(對用戶的形成機制進行nt屏幕)。

示波器列表 - https://developers.google.com/identity/protocols/googlescopes

相關問題