gpt4 book ai didi

java - 谷歌分析 - 缺少 OAuth2Native 类

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:36:13 25 4
gpt4 key购买 nike

我正在尝试运行一个来自 https://developers.google.com/analytics/solutions/articles/hello-analytics-api 的简单示例访问 Google 分析数据。

https://code.google.com/p/google-api-java-client/downloads/list 下载了 java api-library google-api-java-client-1.17.0-rc.zip ,

示例代码显示编译错误:

    private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

private static final JsonFactory JSON_FACTORY = new JacksonFactory();

private static Analytics initializeAnalytics() throws Exception {
Credential credential = OAuth2Native.authorize(
HTTP_TRANSPORT, JSON_FACTORY, new LocalServerReceiver(),
Arrays.asList(AnalyticsScopes.ANALYTICS_READONLY));

Analytics analytics = Analytics.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Hello-Analytics-API-Sample")
.setHttpRequestInitializer(credential)
.build();

我在类路径中添加了所有库,但库似乎没有一些类:

OAuth2Native

AnalyticsScopes

分析

但是这些类存在于 http://code.google.com/p/google-api-java-client/source/browse/shared/shared-sample-cmdline/src/main/java/com/google/api/services/samples/shared/cmdline/oauth2/OAuth2Native.java?repo=samples&r=89662bd8ab341647b3f0aab8ed6a4fb444f478c2

最佳答案

我建议从以下链接下载源代码

hg clone https://code.google.com/p/google-api-java-client.samples/

你必须使用 mercurial为了检查项目。下载后一切顺利,它还向您展示了授权实现的示例。它没有依赖性问题。

关于java - 谷歌分析 - 缺少 OAuth2Native 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19442736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com