Tuesday, January 17, 2012

Re: [YouTube-API] Retrieving insight data though API (Java)

You have specified your developer key, but you haven't authenticated the
request as a specific user.

See here:
<http://code.google.com/apis/youtube/2.0/developers_guide_protocol_authentication.html>

Tim Wintle


On Tue, 2012-01-17 at 02:59 -0800, Mike wrote:
> Hi,
>
> i'm facing 'authentication issue' in youtube api to get the insight
> data csv file link.
>
> given below is my code.
>
>
>
> package sample.youtube;
>
> import java.io.IOException;
> import java.net.MalformedURLException;
> import java.net.URL;
>
> import com.google.gdata.client.Query;
> import com.google.gdata.client.youtube.YouTubeService;
> import com.google.gdata.data.youtube.VideoFeed;
> import com.google.gdata.util.ServiceException;
>
>
>
> public class CSV_Download {
>
> public static final String UPLOADS_URL = "http://gdata.youtube.com/feeds/api/users/default/uploads";
> public static void main(String[] args) {
>
> YouTubeService service = new YouTubeService("insight api", "dev key");
> Query query = null;
> try {
> query = new Query(new URL(UPLOADS_URL));
> } catch (MalformedURLException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> query.setFields("title,entry(title, media:group/media:player)");
> VideoFeed videoFeed = null;
> try {
> videoFeed = service.query(query, VideoFeed.class);
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (ServiceException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> System.out.println(videoFeed.getTitle() + ":");
> System.out.println(" Link : "+videoFeed.getLink("http://gdata.youtube.com/schemas/2007#insight.views", "text/html") + ":");
> }
>
> }
>
>
> the developer token used in this code correct and i'm able to get insight data though UI after login with my credential.
> the error message i'm getting pasted below:
>
>
>
> com.google.gdata.util.AuthenticationException: User authentication required. User authentication required.
>
>
> User authentication required.
> Error 401
> 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.Service.getFeed(Service.java:1135) at com.google.gdata.client.Service.getFeed(Service.java:1077) at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:662) at com.google.gdata.client.Service.query(Service.java:1237) at com.google.gdata.client.Service.query(Service.java:1178) at sample.youtube.CSV_Download.main(CSV_Download.java:30) Exception in thread "main" java.lang.NullPointerException at sample.youtube.CSV_Download.main(CSV_Download.java:38)
>
>
>
>
> So, i inserted line(given below) into the code just after declaring the YouTubeService client:
>
>
> service.setUserCredentials("email_here", "password_here");
>
>
>
> now the authentication error is over and code runs successfully. but, i'm getting Null as link. can anyone help me here? i'm looking for a solution from last 2 weeks.
>
> Thanks,
> Mike
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "YouTube APIs Developer Forum" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/youtube-api-gdata/-/Vb-JHktDwwsJ.
> To post to this group, send email to
> youtube-api-gdata@googlegroups.com.
> To unsubscribe from this group, send email to youtube-api-gdata
> +unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/youtube-api-gdata?hl=en.


--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment