0
我遇到的問題而訪問目錄API來獲取用戶數據:問題,同時通過目錄谷歌API蒲凌用戶信息
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Access Not Configured. Please use Google Developers Console to activate the API for your project.",
"reason" : "accessNotConfigured"
} ],
"message" : "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}.
我用來訪問它的代碼:
Directory service = (Directory) GoogleClientHelper.getClientOAuth20(Directory.Builder.class, email, null, null);
Directory.Users.Get request = service.users().get(email);
User user = request.execute();
然而,以下代碼完美:
Directory service = (Directory) GoogleClientHelper.getClientOAuth20(Directory.Builder.class, email, null, null);
Directory.Users.List request = service.users().list().setCustomer(adminAccount);
do {
try {
Users currentPage = request.execute();
allUsers.addAll(currentPage.getUsers());
request.setPageToken(currentPage.getNextPageToken());
} catch (IOException e) {
System.out.println("An error occurred: " + e);
request.setPageToken(null);
}
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
請支持。
謝謝 葉夫根尼·
它工作。謝謝。 – EVG