Tag: userinfo

从Oauth2 Google Contacts API获取Userinfo

我得到的错误: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized { “code” : 401, “errors” : [ { “domain” : “global”, “location” : “Authorization”, “locationType” : “header”, “message” : “Invalid Credentials”, “reason” : “authError” } ], “message” : “Invalid Credentials” } 下面的代码,我正在使用: GoogleCredential credential = new GoogleCredential.Builder() .setTransport(this.TRANSPORT).setJsonFactory(this.JSON_FACTORY) .setClientSecrets(Constants.CLIENT_ID, Constants.CLIENT_SECRET).build(); credential.setAccessToken(tokenResponse.getAccessToken()); credential.setAccessToken(tokenResponse.getRefreshToken()); 到这里,我得到刷新令牌,访问令牌等 Oauth2 userInfoService = new Oauth2.Builder(this.TRANSPORT, this.JSON_FACTORY, credential.getRequestInitializer()) .setApplicationName(Constants.APPLICATION_NAME).build(); […]