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

user3711987 picture user3711987 · Jun 5, 2014 · Viewed 7.9k times · Source

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?

Answer

azelez picture azelez · Jun 17, 2014

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.