Google Plus API人员列表在客户端登录后不会在服务器上返回任何内容



我有一个web客户端,它登录谷歌并将oauthtoken发送到服务器:

//Api google plus
    (function() {
        var po = document.createElement('script'); 
        po.type = 'text/javascript'; 
        po.async = true;
        po.src = 'https://apis.google.com/js/client.js?onload=onLoadCallback';
        var s = document.getElementsByTagName('script')[0]; 
        s.parentNode.insertBefore(po, s);
    })();
    function onLoadCallback(){
        gapi.client.setApiKey('AIzaSyBXXXXXX'); //set your API KEY
        gapi.client.load('plus', 'v1',function(){});//Load Google + API
    }
    $scope.loginGooglePlus = function() {
      var myParams = {
        'clientid' : 'XXXXXXX',
        'cookiepolicy' : 'single_host_origin',
        'callback': $scope.loginGooglePlusCallback,
        'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.me'
      };
      gapi.auth.signIn(myParams);
    }
    $scope.loginGooglePlusCallback = function(result){
        if(result['status']['signed_in']){ 
            //alert("Login Success");
            console.log(result);
            UserAuth.loginGooglePlus(result.access_token);
        }   
    }

所以,在服务器上,我试图获得这样的人的朋友列表:

String graphFace = "https://www.googleapis.com/plus/v1/people/me/people/visible?key=XXXXXXXXXXXXXXX&access_token=" + oauthToken;
                urlAccess = new URL(graphFace);
                URLConnection faceConnection = urlAccess.openConnection();
                faceConnection.setRequestProperty("Content-Type", "application/json;charset=utf-8;");
                BufferedReader in = new BufferedReader( new InputStreamReader(faceConnection.getInputStream()));
                String fileJson = "", strJson = "";
                while ((strJson = in.readLine()) != null)
                    fileJson = fileJson + strJson + "n";
                createFriendTopologyFromGoogle(person, fileJson);

人员列表总是空的。但是如果我在API资源管理器中执行相同的命令(https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.list)一切都很好。

这个命令人员列表只适用于客户端吗?

https://www.googleapis.com/plus/v1/people/me/people/visible?key={APIKey}

将返回

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "authError",
    "message": "Invalid Credentials",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Invalid Credentials"
 }
}

因为它需要身份验证,请尝试发送以下

https://www.googleapis.com/plus/v1/people/me/people/visible?access_token={Token from oauth2 authentcation}

我解决了进入https://plus.google.com/u/0/apps并释放我的应用程序的所有权限。我在2个用户上这样做。

现在,我需要登录已经拥有此权限的用户。我不知道这部分。

相关内容

  • 没有找到相关文章

最新更新