title: Java Google Youtube Data API:: Unauthorized
body: <p>I wanted to upload a video on youtube using Java Google Data API. I got the following cod from the Google Data Api documentation to upload a video.The only thing i need to change in this code in Client ID and Porduct key. i am using followinf method to authenticate</p>
  
  <p>YouTubeService service = new YouTubeService(clientID, developer_key);</p>
  
  <p>Client key is my Google Email id , tried with with wasy,</p>
  
  <ul>
  <li>only provided Username e,g. "sampleuser"</li>
  <li>or complete Gmail id e.g. "sampleuser@gmail.com" or "smapleuser@googlemail.com"</li>
  </ul>
  
  <p>i got developer key by logging my Google mail id as mentioned "smapleuser@googlemail.com"</p>
  
  <p>but i always got following exception</p>
  
  <pre><code>com.google.gdata.util.AuthenticationException: Unauthorized
  at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600)
  at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
  at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
  at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
  at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
  at com.google.gdata.client.media.MediaService.insert(MediaService.java:400)
  at YouTube.videoUpload(YouTube.java:115)
  at YouTube.main(YouTube.java:43)
  </code></pre>
  
  <p>here is my code for video Upload</p>
  
  <pre><code>YouTubeService service = new YouTubeService("sampleuser@gmail.com",
              "fakegoogleapplicationidjsuttoshowthatimgivingidhere");
      // YouTubeService service = new YouTubeService("My Application");
      VideoEntry newEntry = new VideoEntry();
  
      YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
      mg.setTitle(new MediaTitle());
      mg.getTitle().setPlainTextContent("My Test Movie");
      mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos"));
      mg.setKeywords(new MediaKeywords());
      mg.getKeywords().addKeyword("cars");
      mg.getKeywords().addKeyword("funny");
      mg.setDescription(new MediaDescription());
      mg.getDescription().setPlainTextContent("My description");
      mg.setPrivate(false);
      mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag"));
      mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "anotherdevtag"));
  
      newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0));
      // alternatively, one could specify just a descriptive string
      // newEntry.setLocation("Mountain View, CA");
  
      MediaFileSource ms = new MediaFileSource(new File("D:\\maths.mp4")
      , "video/quicktime");
      newEntry.setMediaSource(ms);
  
      // "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
      String uploadUrl =
          "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
  
      try {
          VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
      } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (ServiceException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>please help , unable to find solution. thank you so much..looking for response</p>