0

YouTube Java API を使用して Java デスクトップ アプリケーションを介して YouTube アカウントに接続しようとしています。簡単ですが、エラーが発生しました。私のコードは次のとおりです。

    String developer_key = "key123456789"; // Registered developer key
    String application_name = "app"; // Registered application name
    String user_account = "user@gmail.com"; // Server's Youtube account
    String user_password = "mypass"; // Server's Youtube password

    YouTubeService service = new YouTubeService(application_name, developer_key);

    try {
        service.setUserCredentials(user_account, user_password);
    } catch (AuthenticationException e) {
        System.out.println("Error: " + e);
    }

しかし、私はこのエラーを受け取り続けます:

com.google.gdata.util.AuthenticationException: Error connecting with login URI

setUserCredentials 関数でエラーが発生しています。何が欠けているか知っていますか?

4

1 に答える 1

0

私は問題を発見しました、私はプロキシの下にいます(私はすでにこのプロキシに接続するようにシステムプロパティを変更していました)が、YouTubeはhttpではなくユーザーログインにhttpsを使用するため、プロキシ設定でhttpsプロキシを追加しましたそして今動作します、ここに私のコードがあります:

        if(Assets.HTTP_USE_PROXY) {
        System.setProperty("proxySet", "true");
        System.setProperty("https.proxyHost", Assets.HTTP_PROXY_HOST);
        System.setProperty("https.proxyPort", Integer.toString(Assets.HTTP_PROXY_PORT));
        if(Assets.HTTP_REQUIRE_AUTH) {
            System.setProperty("https.proxyUser", Assets.HTTP_PROXY_USER);
            System.setProperty("https.proxyPassword", Assets.HTTP_PROXY_PASSWORD);
            Authenticator.setDefault(
                      new Authenticator() {
                        public PasswordAuthentication getPasswordAuthentication() {
                          return new PasswordAuthentication(Assets.HTTP_PROXY_USER, 
                                  Assets.HTTP_PROXY_PASSWORD.toCharArray());
                        }
                      }
                    );
        }
    }
于 2013-10-01T14:35:12.853 に答える