2016-04-01 12 views
2

Bir Android uygulamasından Picasa'ya fotoğraf yüklemeye çalışıyorum. Google Tek Oturum Açma'yı kullanarak giriş yaptım ve erişim belirtecini oradan aldım.Picasa API Fotoğraf Yükle: Başlarken 403/Geçersiz Jeton

Yeni bir albüm oluşturmaya çalışırken, Geçersiz Jetonu döndüren benzer bir hata alıyorum.

Bu albümlerdeki herkese açık albümleri ve fotoğrafları almak için GET çağrıları yapabilirim, ancak POST isteği yok. İşte

Ben

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(); 
} 

cevap

0

httpPost.setHeader("Authorization", "GoogleLogin auth=" + mPreferences.getAccessToken()); 

değiştirerek bu çözme sona erdi

httpPost.setHeader("Authorization", "OAuth " + mPreferences.getAccessToken()); 
için depodan bir fotoğraf yüklemek için çalışıyorum nasıl