Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 404访问youtube api数据时出错_Java_Oauth 2.0_Youtube Api - Fatal编程技术网

Java 404访问youtube api数据时出错

Java 404访问youtube api数据时出错,java,oauth-2.0,youtube-api,Java,Oauth 2.0,Youtube Api,我开发了一个独立的程序,根据资产id查找视频id。为此,我使用服务帐户身份验证生成访问令牌。当我在url中传递访问令牌时,它显示404未找到异常。有人遇到过这样的问题吗 代码: 提前谢谢 请包括您正在运行的导致此错误的代码。请在您的问题中包括此错误的代码。嗨,denise..我在这里添加了代码..请检查我是否为您编辑了问题。这些信息可能足够有人回答了。 String EmailId = "xxxxxx@developer.gserviceaccount.com"; //

我开发了一个独立的程序,根据资产id查找视频id。为此,我使用服务帐户身份验证生成访问令牌。当我在url中传递访问令牌时,它显示404未找到异常。有人遇到过这样的问题吗

代码:


提前谢谢

请包括您正在运行的导致此错误的代码。请在您的问题中包括此错误的代码。嗨,denise..我在这里添加了代码..请检查我是否为您编辑了问题。这些信息可能足够有人回答了。
String EmailId = "xxxxxx@developer.gserviceaccount.com";

            //passing Scope
            @SuppressWarnings({ "unchecked", "rawtypes" })
              List<String>scops = new <String>ArrayList();
              scops.add("https://www.googleapis.com/auth/youtubepartner");

            final HttpTransport TRANSPORT = new NetHttpTransport();
            final JsonFactory JSON_FACTORY = new JacksonFactory();

         // Create a listener for automatic refresh OAuthAccessToken
            List<CredentialRefreshListener> list = new ArrayList<CredentialRefreshListener>();
            list.add(new CredentialRefreshListener() {
                @Override
                public void onTokenResponse(Credential credential,
                        TokenResponse tokenResponse) throws IOException {
                    System.out.println(tokenResponse.toPrettyString());

                }

                public void onTokenErrorResponse(Credential credential,
                        TokenErrorResponse tokenErrorResponse)
                        throws IOException {
                    System.err.println("Error: "
                            + tokenErrorResponse.toPrettyString());
                }


            });
            GoogleCredential credential = new GoogleCredential.Builder()
            .setTransport(TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId(EmailId)
            .setServiceAccountScopes(scops)
            .setServiceAccountPrivateKeyFromP12File(new File("xxxxxx.p12"))
            .setRefreshListeners(list)
            .build();
            /*YouTube youtube = new YouTube.Builder(TRANSPORT,
                    JSON_FACTORY, credential).setApplicationName("test1-bd3f7f252932").build();*/
            credential.refreshToken();
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}