我正在尝试使用服务用户()使用Java从GSC Search Analytics API中获取数据。
<ldap>
<connectionUrl>wehavenoidea:389</connectionUrl>
<roleBase>OU=AADDC Users,DC=ourdomain,DC=onmicrosoft,DC=com</roleBase>
<userPattern>{0},OU=AADDC Users,DC=ourdomain,DC=onmicrosoft,DC=com</userPattern>
<roleSearch>member={0}</roleSearch>
<useIndirectLookup>1</useIndirectLookup>
<indirectAdminDN>CN=AdminUser,OU=AADDC Users,DC=ourdomain,DC=onmicrosoft,DC=com</indirectAdminDN>
<indirectAdminPassword>ourpassword</indirectAdminPassword>
<indirectUserBase>DC=ourdomain,DC=onmicrosoft,DC=com</indirectUserBase>
<indirectSearchFilter>sAMAccountName={0}</indirectSearchFilter>
<rolemap>
<role target="Admin">Admin</role>
<role target="Accounting">Accounting</role>
</rolemap>
</ldap>
获取错误:
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
GoogleCredential credential = null;
try {
credential = GoogleCredential.fromStream(new FileInputStream(KEY_FILE_LOCATION)).createScoped(Collections.singleton(WebmastersScopes.WEBMASTERS));
} catch (IOException e) {
throw new IllegalStateException(e);
}
// Create a new authorized API client
Webmasters webmasters = new Webmasters.Builder(httpTransport, jsonFactory, credential).setApplicationName("Search Console Cli").build();
SearchAnalyticsQueryResponse searchAnalyticsQueryResponse = webmasters.searchanalytics().query("https://abc.xyz.com", query).execute();
步骤:
使用服务帐户用户使用OAuth 2.0授权请求是否必须使用Google Analytics(分析)帐户?
根据google文档链接(https://developers.google.com/webmaster-tools/search-console-api-original/v3/how-tos/authorizing#AboutAuthorization),您可以为Web应用程序,服务帐户或已安装的应用程序生成OAuth 2.0凭据。
请建议我是否有任何遗漏。
注意:我没有拥有网站https://abc.xyz.com的Google Analytics(分析)帐户。我只有Google Search Console帐户。