Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Auth.HTTP_TRANSPORT and Auth.JSON_FACTORY not found for Youtube.Builder

$
0
0

I'm trying to run the following but I'm getting the error message below:

import com.google.api.client.googleapis.json.GoogleJsonResponseException;import com.google.api.client.http.HttpRequest;import com.google.api.client.http.HttpRequestInitializer;import com.google.api.services.youtube.YouTube;import com.google.api.services.youtube.model.ResourceId;import com.google.api.services.youtube.model.SearchListResponse;import com.google.api.services.youtube.model.SearchResult;import com.google.api.services.youtube.model.Thumbnail;import java.io.IOException;import java.util.List;import static java.lang.System.out;public class Search {    public static void main(String[] args) {        try {            YouTube youtube = new YouTube.Builder(                    Auth.HTTP_TRANSPORT,                    Auth.JSON_FACTORY,                    new HttpRequestInitializer() {                        public void initialize(HttpRequest request) throws IOException {                        }                    })                    .setApplicationName("application_name")                    .build();            String queryTerm = "cats";            YouTube.Search.List search = youtube                    .search()                    .list("id,snippet");            String apiKey = "AIzaSyDiVWbm1q3s3cI3RZNCfH85hXS95H8opgs";            search.setKey(apiKey);            search.setQ(queryTerm);            // Valid types: "channel" "playlist" "video"            search.setType("video");            search.setFields("items(id/kind,id/videoId,snippet/title," +"snippet/description,snippet/thumbnails/default/url)");            search.setMaxResults(10L);            SearchListResponse searchResponse = search.execute();            List<SearchResult> searchResultList = searchResponse.getItems();            SearchResult video = searchResultList.iterator().next();            Thumbnail thumbnail = video.getSnippet().getThumbnails().getDefault();            out.println("Kind: " + video.getKind());            out.println("Video Id: " + video.getId().getVideoId());            out.println("Title: " + video.getSnippet().getTitle());            out.println("Description: " + video.getSnippet().getDescription());            out.println("Thumbnail: " + thumbnail.getUrl());        } catch (GoogleJsonResponseException ex) {            ex.printStackTrace();        } catch (IOException ex) {            ex.printStackTrace();        }    }}

Here is the error message :


ch02_search/Search.java:[49,21] cannot find symbol symbol:
variable Auth location: class ch02_search.Searchch02_search/Search.java:[50,21] cannot find symbol symbol:
variable Auth location: class ch02_search.Search 2 errors


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>