Why does not the authorization occur? : I implement search in my application. I try to implement the proposed in the seventh answer https://stackoverflow.com/questions/3727662/how-can-you-search-google-programmatically-java-api option. I insert my keys, but for some reason I do not pass authorization. Someone can tell me what I'm doing wrong. Below is my code.

I use the com_google_apis_google_api_services_customsearch_v1_rev74_1_25_0.xml library
I get the result:
run:
cs= com.google.api.services.customsearch.Customsearch@16b3fc9e
list= {cx=MyCx, key=MyKey, q=test}
IOException result
 result= null
tried NB 8.2 и IntelliJ IDEA 

    import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
    import com.google.api.client.json.jackson2.JacksonFactory;
    import com.google.api.services.customsearch.Customsearch;
    import 
    com.google.api.services.customsearch.CustomsearchRequestInitializer;
    import com.google.api.services.customsearch.model.Result;
    import com.google.api.services.customsearch.model.Search;

    import java.io.IOException;
    import java.security.GeneralSecurityException;

    public class Main {
    public static void main(String[] args) throws GeneralSecurityException, 
    IOException {

        //  String searchQuery = "test"; //The query to search
        //  String cx = "MyCx"; //Your search engine

        String searchQuery = "test"; //The query to search
        String cx = "MyCx"; //Your search engine


        //Instance Customsearch
        Customsearch cs= null;
        try {
            cs = new Customsearch.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), null)
                    .setApplicationName("MYApp")
                    .setGoogleClientRequestInitializer(new CustomsearchRequestInitializer("MyKey"))
                    .build();
            System.out.println("cs= "+cs);
        } catch (GeneralSecurityException e) {
            System.out.println("GeneralSecurityException cs");
        } catch (IOException e) {
            System.out.println("IOException cs");

        } catch (Exception e) {
            System.out.println("Exception cs");
        }

        //Set search parameter
        Customsearch.Cse.List list = null;
        try {
            list = cs.cse().list(searchQuery).setCx(cx);
            System.out.println("list= "+list);
        } catch (IOException e) {
            System.out.println("IOException list");
        }


        //Execute search
        Search result= null;
        try {
            result = list.execute();
        } catch (IOException e) {
            System.out.println("IOException result");
        }

        if (result!=null) { if  (result.getItems()!=null){
            for (Result ri : result.getItems()) {
                //Get title, link, body etc. from search
                System.out.println(ri.getTitle() + ", " + ri.getLink());
            }

        }  else {  System.out.println(" resultgetItems()= null"); }
        }  else {  System.out.println(" result= null"); }
      }

    }


The code seems to be correct, I would like to understand what you need to do to log in.