Hi,
I am trying to call (in Java) PicasawebService.getFeed after using
PicasawebService.setAuthSubToken with a private key.
I get:
Token invalid - Invalid AuthSub token.
The problem is that the "Authorization:" header generated by
PicasawebService.getFeed is wrong. According to the doc, it should
look like this:
Authorization: AuthSub token="token" sigalg="sigalg" data="data"
sig="sig"
However, what is actually sent is this:
Authorization: AuthSub token="token"
As the token is a secure session token, I get "Invalid AuthSub token".
I can get the album list with the same token if I try it from command
line with curl. So the token is OK, as long as I form a correct
"Authorization:" header.
here is the code (I replaced the actual app name with some random
string, but I use a real, registered with a private key, app to test
this)
import java.io.File;
import java.net.URL;
import com.google.gdata.client.*;
import com.google.gdata.client.photos.*;
import com.google.gdata.data.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.photos.*;
import com.google.gdata.client.http.AuthSubUtil;
class MakePublicAlbum {
public static void main (String[] args)
{
// Args: 0: username 1:token
int errcode = 0;
try {
java.security.PrivateKey privateKey =
AuthSubUtil.getPrivateKeyFromKeystore("/etc/lighttpd/
dbasecurity.jks", "password", "myapp.com", "");
PicasawebService picserv = new PicasawebService("MyApp");
picserv.setAuthSubToken(args[1],privateKey);
URL feedUrl = new
URL("https://picasaweb.google.com/data/feed/api/
user/"+args[0]+"?kind=album");
// This fails
UserFeed myUserFeed = picserv.getFeed(feedUrl, UserFeed.class);
for (AlbumEntry myAlbum : myUserFeed.getAlbumEntries()) {
System.out.println(myAlbum.getTitle().getPlainText());
}
} catch (Exception e ) {
System.out.println("Picasa web services error: ");
System.out.println(e.toString());
System.out.println(e.getMessage());
e.printStackTrace();
errcode = 1;
}
}
};
--
You received this message because you are subscribed to the Google Groups
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-picasa-data-api?hl=en.