2014-07-27 72 views
0

我已經成功authenticedated使用範圍,以谷歌:如何成功登錄後獲得電子郵件和個人資料,谷歌

var scopes=['email','profile','https://www.googleapis.com/auth/drive']; 

我用這個嘗試讀取用戶的電子郵件和個人資料:

function getEmail(resp) 
{ 
    var email,isFound=false; 
    console.log(resp); 
    for(var i=0;i<resp.emails.length && !isFound;i++) 
    { 
    if(resp.emails[i].type==='account') 
    { 
     email=resp.emails[i].value; 
     isFound=true 
    } 
    } 
    return email;  
} 

function getProfile(resp) 
{ 
    console.log(resp); 
    console.log("Retrieved profile for "+resp.displayName); 
} 

function handleResponse(resp) 
{ 
    var email=getEmail(resp); 
    var profile=getProfile(resp); 
} 

裏面handleAuthResult我打電話:

gapi.client.load('plus','v1',function(){ 
    //request profile information 
    var request=gapi.client.plus.people.get({ 
     'userid':'me', 
    }); 
    //execute the request 
    request.execute(handleResponse); 

}); 

取而代之的是用戶的電子郵件和個人資料頁面,我得到如下回應:

{ 
"code": 403, 
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project.", 
"data": [ 
    { 
     "domain": "usageLimits", 
     "reason": "accessNotConfigured", 
     "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project." 
    } 
], 
"error": { 
    "code": 403, 
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project.", 
    "data": [ 
     { 
      "domain": "usageLimits", 
      "reason": "accessNotConfigured", 
      "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project." 
     } 
    ] 
} 
} 

我在Google API Console打開了Google+ API得到這個:

{ 
"code": 404, 
"message": "Not Found", 
"data": [ 
    { 
     "domain": "global", 
     "reason": "notFound", 
     "message": "Not Found" 
    } 
], 
"error": { 
    "code": 404, 
    "message": "Not Found", 
    "data": [ 
     { 
      "domain": "global", 
      "reason": "notFound", 
      "message": "Not Found" 
     } 
    ] 
} 
}  
+0

可能重複:http://stackoverflow.com/questions/22870082/getting-error-403-access-not-configured-please-use-google-developers- console-t – Sid

+0

@Sid我正在使用Referrers設置中允許的任何引用。 – vamsiampolu

+0

該問題包含其他解決方案。你嘗試過那些嗎? – Sid

回答

0

userid參數是區分大小寫的,應該是userId代替。

我測試過並使用userid結果中顯示404錯誤信息,而userId適合我。在此情況下,一個非常有用的錯誤信息......

+0

@Scarygemi我得到了一個403要求我'訪問未配置。請使用谷歌開發者控制檯啓用API爲您project.'I有'驅動API',在Google+的'和API''聯繫人API'活躍,我在這裏失蹤 – vamsiampolu

+0

我使用了不同的API密鑰和它的工作。 – vamsiampolu

相關問題