Having trouble importing “google.api.services.samples.youtube.cmdline.Auth;”?

做~自己de王妃 提交于 2019-11-30 00:31:01

问题


I followed this tutorial https://developers.google.com/youtube/v3/code_samples/java#search_by_keyword

to retreive youtube videos based on keyword using YouTubeData API

This section is giving me the error: "Error:(117, 43) error: cannot find symbol variable auth"

youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
                public void initialize(com.google.api.client.http.HttpRequest request) throws IOException {
                }
            })
                    .setApplicationName("youtube-cmdline-search-sample")
                    .build();

I think that this class is not being imported

import com.google.api.services.samples.youtube.cmdline.Auth;

I've searched the internet for someone else having this problem but the question was never answered....can someone please help me?


回答1:


These two defines can be found in the youtube example: Auth.java file from example

Are you can just replace the Builder string as follows:

new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer() 

This will do the trick, same as finding the defines.

Hopes this helps, BR, Adrian.



来源:https://stackoverflow.com/questions/24065065/having-trouble-importing-google-api-services-samples-youtube-cmdline-auth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!