Ich versuche, Fotos von einer Android-Anwendung auf Picasa hochzuladen. Ich habe mich mit Google Single Sign On angemeldet und das Zugriffstoken von dort abgerufen.Picasa-API Foto hochladen: 403/ungültiges Token erhalten
Beim Versuch, ein neues Album zu erstellen, erhalte ich einen ähnlichen Fehler, der ungültiges Token zurückgibt.
Ich kann GET-Anrufe tätigen, die öffentliche Alben und Fotos in diesen Alben abrufen, aber keine POST-Anfragen.
Hier ist, wie ich
String url = "https://picasaweb.google.com/data/feed/api/user/" + mPreferences.getUsername() + "/albumid/" + mAlbumID;
HttpClient httpClient = new DefaultHttpClient();
File file = new File("/storage/emulated/0/Pictures/Screenshots/scrn.png");
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("GData-Version", "2");
httpPost.setHeader("Content-type", "image/jpeg");
httpPost.setHeader("Slug", "plz-to-love-realcat.jpg");
httpPost.setHeader("Authorization", "GoogleLogin auth=" + mPreferences.getAccessToken());
InputStreamEntity reqEntity;
org.apache.http.HttpResponse response;
try {
reqEntity = new InputStreamEntity(new FileInputStream(file), file.length());
String CONTENTTYPE_BINARY = "binary/octet-stream";
reqEntity.setContentType(CONTENTTYPE_BINARY);
reqEntity.setChunked(true);
httpPost.setEntity(reqEntity);
response = httpClient.execute(httpPost);
Log.d("Picasa Upload", "STATUS CODE : " + response.getStatusLine().getStatusCode());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}