console authentication

29 views
Skip to first unread message

Thufir

unread,
May 25, 2009, 4:19:00 AM5/25/09
to google-he...@googlegroups.com
I'm just playing around with the code at:

http://code.google.com/apis/gdata/client-java.html#Tutorial


I want to get an SID and so forth from this; any pointers?

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package auth;

import com.google.gdata.client.GoogleService;
import com.google.gdata.data.Feed;
import com.google.gdata.data.extensions.EventFeed;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
import static java.lang.System.out;
import static java.lang.System.in;

/**
*
* @author thufir
*/
public class Main {

private static String userPrefix, userSuffix =
"@gmail.com",user,password;

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws MalformedURLException,
AuthenticationException, IOException, ServiceException {


BufferedReader br = new BufferedReader(new InputStreamReader(in));
out.print("user:\t");
user = br.readLine() + userSuffix;
out.print("password:\t");
password = br.readLine();

out.println("\n\nlogging in with\n"+user+"\t\t"+password);

URL feedUrl = new URL("http://www.google.com/calendar/feeds/
l...@gmail.com/private/full");
GoogleService myService = new GoogleService("cl", "exampleCo-
exampleApp-1");
myService.setUserCredentials(userPrefix, password);

// Mark the feed as an Event feed:
new EventFeed().declareExtensions(myService.getExtensionProfile
());

// Send the request and receive the response:
Feed myFeed = myService.getFeed(feedUrl, Feed.class);

out.println(myFeed);


}
}

thanks,

Thufir

Thufir

unread,
May 27, 2009, 6:40:43 AM5/27/09
to google-he...@googlegroups.com
Even after adding google collections and jsr 305 to the class path via
netbeans the same run-time exception occurs, which I understand to mean
that com.google.common.collect.Maps cannot be found on the class path,
and yet there it is. (Granted, I created a "gdata" library and just
threw in all the gdata jars, but I don't see how that would be a problem.)

Is there some way of troubleshooting this? I'm out of ideas :(

[thufir@arrakis dist]$
[thufir@arrakis dist]$
[thufir@arrakis dist]$
[thufir@arrakis dist]$ pwd
/home/thufir/NetBeansProjects/auth/dist
[thufir@arrakis dist]$
[thufir@arrakis dist]$ ll
total 16
-rw-rw-r-- 1 thufir thufir 5917 2009-05-27 03:27 auth.jar
drwxrwxr-x 2 thufir thufir 4096 2009-05-27 03:27 lib
-rw-rw-r-- 1 thufir thufir 1442 2009-05-27 03:27 README.TXT
[thufir@arrakis dist]$
[thufir@arrakis dist]$
[thufir@arrakis dist]$ java -jar auth.jar
user: foo
password: bar


logging in with
f...@gmail.com bar
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/
common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>
(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>
(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:513)
at auth.Main.main(Main.java:44)
Caused by: java.lang.ClassNotFoundException:
com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
... 4 more
[thufir@arrakis dist]$
[thufir@arrakis dist]$ ll lib/google-collections-1.0-rc1-sources.jar
-rw-rw-r-- 1 thufir thufir 274317 2009-05-27 03:27 lib/google-
collections-1.0-rc1-sources.jar
[thufir@arrakis dist]$
[thufir@arrakis dist]$ ll lib/jsr305-1.3.8.jar
-rw-rw-r-- 1 thufir thufir 31866 2009-05-27 03:27 lib/jsr305-1.3.8.jar
[thufir@arrakis dist]$
[thufir@arrakis dist]$ jar -xf auth.jar
[thufir@arrakis dist]$
[thufir@arrakis dist]$ cat auth/Main.java

out.println(myFeed);


}
}
[thufir@arrakis dist]$
[thufir@arrakis dist]$ cat META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 14.0-b08 (Sun Microsystems Inc.)
Main-Class: auth.Main
Class-Path: lib/gdata-analytics-1.0.jar lib/gdata-analytics-meta-1.0.j
ar lib/gdata-appsforyourdomain-1.0.jar lib/gdata-appsforyourdomain-me
ta-1.0.jar lib/gdata-base-1.0.jar lib/gdata-blogger-2.0.jar lib/gdata
-blogger-meta-2.0.jar lib/gdata-books-1.0.jar lib/gdata-books-meta-1.
0.jar lib/gdata-calendar-2.0.jar lib/gdata-calendar-meta-2.0.jar lib/
gdata-client-1.0.jar lib/gdata-client-meta-1.0.jar lib/gdata-codesear
ch-2.0.jar lib/gdata-codesearch-meta-2.0.jar lib/gdata-contacts-2.0.j
ar lib/gdata-contacts-meta-2.0.jar lib/gdata-core-1.0.jar lib/gdata-d
ocs-2.0.jar lib/gdata-docs-meta-2.0.jar lib/gdata-finance-2.0.jar lib
/gdata-finance-meta-2.0.jar lib/gdata-health-2.0.jar lib/gdata-health
-meta-2.0.jar lib/gdata-maps-2.0.jar lib/gdata-maps-meta-2.0.jar lib/
gdata-media-1.0.jar lib/gdata-photos-1.0.jar lib/gdata-photos-meta-1.
0.jar lib/gdata-spreadsheet-2.0.jar lib/gdata-spreadsheet-meta-2.0.ja
r lib/gdata-webmastertools-2.0.jar lib/gdata-webmastertools-meta-2.0.
jar lib/gdata-youtube-2.0.jar lib/gdata-youtube-meta-2.0.jar lib/goog
le-collections-1.0-rc1-sources.jar lib/jsr305-1.3.8.jar
X-COMMENT: Main-Class will be added automatically by build

[thufir@arrakis dist]$
[thufir@arrakis dist]$


-Thufir

Reply all
Reply to author
Forward
0 new messages