我在java中使用管分析api。我有一个jsp页面,它调用一个编写此代码的servlet -
final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
/** Global instance of the JSON factory. */
final JsonFactory JSON_FACTORY = new JacksonFactory();
/** Global instance of Youtube object to make general YouTube API requests. */
YouTube youtube;
/** Global instance of YoutubeAnalytics object to make analytic API requests. */
YouTubeAnalytics analytics;
Reader reader = new InputStreamReader(YouTubeAnalyticsReports.class.getResourceAsStream("client_secrets.json"));
String access_token = null;
String id = null;
// Scopes required to access YouTube general and analytics information.
List<String> scopes = Lists.newArrayList(
"https://www.googleapis.com/auth/yt-analytics.readonly",
"https://www.googleapis.com/auth/youtube.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
);
try {
Credential credential = YouTubeAnalyticsReports.authorize(scopes);
}
catch (Exception e) {
System.err.println("IOException: " + e.getMessage());
e.printStackTrace();
}
执行此代码后,在浏览器中打开一个新选项卡以自动化用户,然后保存凭据。但是jsp页面调用servlet的选项卡总是在此之后显示加载。因此,如果我再次尝试执行此代码,那么它会提供流关闭异常。现在该怎么做
答案 0 :(得分:0)
我找到了这个解决方案....我没有使用Desktop.Browse作为网址。现在我只是获取网址并在同一个标签中打开网址。