gdata picasa client using oauth2 playground


/ Published in: Bash
Save to your folder(s)

auth2 playground at https://code.google.com/oauthplayground/

series of http requests to get auth token and then to request a couple of api URL's


Copy this code and paste it in your HTML
  1. 2 needed URLs :
  2.  
  3. picasaweb.google.com/data/feed/api/user/rowntreerob/albumid/5677569274306148065?fields=@gd:*,entry/gphoto:id,entry/gphoto:timestamp
  4.  
  5. picasaweb.google.com/data/feed/api/user/rowntreerob/albumid/5677569274306148065/photoid/5677569495943071042?fields=entry/link[@rel="edit"]
  6.  
  7. series of actual requests to oauth and then to the gdata api ( picasa )
  8.  
  9. authorize api:
  10.  
  11. GET /oauthplayground/?code=4/UuiRSrHbrT0R4sO1Bmc5Z68UgDlY HTTP/1.1
  12. Host: code.google.com
  13.  
  14. HTTP/1.1 302 Found
  15. Location: https://accounts.google.com/o/oauth2/auth?redirect_uri=https%3A%2F%2Fcode.google.com%2Foauthplayground
  16. %2F&response_type=code&client_id=99999999999.apps.googleusercontent.com&approval_prompt=force&
  17.  
  18. scope=https%3A%2F%2Fpicasaweb.google.com%2Fdata%2F&access_type=offline
  19.  
  20. ==
  21.  
  22.  
  23. exchng authorization for access token:
  24.  
  25. POST /o/oauth2/token HTTP/1.1
  26. Host: accounts.google.com
  27. content-type: application/x-www-form-urlencoded
  28. user-agent: google-oauth-playground
  29. code=4%2FUuiRSrHbrT0R4sO1Bmc5Z68UgDlY&
  30. redirect_uri=https%3A%2F%2Fcode.google.com%2Foauthplayground%2F
  31. &client_id=999999999999.apps.googleusercontent.com&scope=
  32. &client_secret=************&grant_type=authorization_code
  33.  
  34. HTTP/1.1 200 Ok
  35. status: 200
  36. content-length: 196
  37. x-xss-protection: 1; mode=block
  38. x-content-type-options: nosniff
  39. expires: Fri, 01 Jan 1990 00:00:00 GMT
  40. x-google-cache-control: remote-fetch
  41. server: GSE
  42. via: HTTP/1.1 GWA
  43. pragma: no-cache
  44. cache-control: no-cache, no-store, max-age=0, must-revalidate
  45. date: Mon, 12 Dec 2011 18:38:08 GMT
  46. x-frame-options: SAMEORIGIN
  47. content-type: application/json
  48. -content-encoding: gzip
  49. {
  50. "access_token" : "ya29.AHES6ZSFQemR-du82WUi0R_lqJJL74_kR2HXbB6p75Q5J28",
  51. "token_type" : "Bearer",
  52. "expires_in" : 3600,
  53. "refresh_token" : "1/Xe6b_vIViKwQiFFnTmEygoy3GzE5KfatAZqvrFtW08w"
  54. }
  55.  
  56.  
  57. Get a series of photo timestamps from the album
  58. ==
  59. add http hdr GData-Version : 2
  60. ==
  61. GET /data/feed/api/user/rowntreerob/albumid/5677569274306148065?fields=@gd:*,entry/gphoto:id,entry/gphoto:timestamp HTTP/1.1
  62. Host: picasaweb.google.com
  63. GData-Version: 2
  64. Authorization: OAuth ya29.AHES6ZSFQemR-du82WUi0R_lqJJL74_kR2HXbB6p75Q5J28
  65.  
  66.  
  67. HTTP/1.1 200 OK
  68. status: 200
  69. gdata-version: 2.0
  70. content-length: 3500
  71. via: HTTP/1.1 GWA
  72. content-location: https://picasaweb.google.com/data/feed/api/user/rowntreerob/albumid/5677569274306148065?fields=@gd:*,entry/gphoto:id,entry/gphoto:timestamp
  73. x-content-type-options: nosniff
  74. set-cookie: _rtok=PGdAQg3s3pC8; Path=/; Secure; HttpOnly, S=photos_html=lm4SDkufb3i0PYW2lZveEQ; Domain=.google.com; Path=/; Secure; HttpOnly
  75. expires: Mon, 12 Dec 2011 18:40:50 GMT
  76. vary: Accept, X-GData-Authorization, GData-Version, Cookie
  77. x-google-cache-control: remote-fetch
  78. server: GSE
  79. last-modified: Mon, 28 Nov 2011 19:57:09 GMT
  80. x-xss-protection: 1; mode=block
  81. etag: W/"CkUGSHYyeCp7ImA9WhRRFUw."
  82. cache-control: private, max-age=0, must-revalidate, no-transform
  83. date: Mon, 12 Dec 2011 18:40:50 GMT
  84. x-frame-options: SAMEORIGIN
  85. content-type: application/atom+xml; charset=UTF-8; type=feed
  86. -content-encoding: gzip
  87.  
  88. <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;CkUGSHYyeCp7ImA9WhRRFUw.&quot;' gd:fields='@gd:*,entry/gphoto:id,entry/gphoto:timestamp'><entry><gphoto:id>5677569292818283634</gphoto:id><gphoto:timestamp>1321879579000</gphoto:timestamp></entry><entry><gphoto:id>5677569322606354754</gphoto:id><gphoto:timestamp>1321879606000</gphoto:timestamp></entry><entry><gphoto:id>5677569342889525810</gphoto:id><gphoto:timestamp>1321879621000</gphoto:timestamp></entry><entry><gphoto:id>5677569368215390914</gphoto:id><gphoto:timestamp>1321879662000</gphoto:timestamp></entry><entry><gphoto:id>5677569385204261106</gphoto:id><gphoto:timestamp>1321879673000</gphoto:timestamp></entry><entry><gphoto:id>5677569415988585282</gphoto:id><gphoto:timestamp>1321879689000</gphoto:timestamp></entry><entry><gphoto:id>5677569452195798690</gphoto:id><gphoto:timestamp>1321879719000</gphoto:timestamp></entry><entry><gphoto:id>5677569477327748130</gphoto:id><gphoto:timestamp>1321879745000</gphoto:timestamp></entry><entry><gphoto:id>5677569495943071042</gphoto:id><gphoto:timestamp>1321879755000</gphoto:timestamp></entry><entry><gphoto:id>5677569521154963874</gphoto:id><gphoto:timestamp>1321879823000</gphoto:timestamp></entry><entry><gphoto:id>5677569555161637890</gphoto:id><gphoto:timestamp>1321879970000</gphoto:timestamp></entry><entry><gphoto:id>5677569572283417122</gphoto:id><gphoto:timestamp>1321879994000</gphoto:timestamp></entry><entry><gphoto:id>5677569598786243922</gphoto:id><gphoto:timestamp>1321880064000</gphoto:timestamp></entry><entry><gphoto:id>5677569627413415234</gphoto:id><gphoto:timestamp>1321880079000</gphoto:timestamp></entry><entry><gphoto:id>5677569651000334690</gphoto:id><gphoto:timestamp>1321880106000</gphoto:timestamp></entry><entry><gphoto:id>5677569681089735218</gphoto:id><gphoto:timestamp>1321880122000</gphoto:timestamp></entry><entry><gphoto:id>5677569713514297042</gphoto:id><gphoto:timestamp>1321880152000</gphoto:timestamp></entry><entry><gphoto:id>5677569735745025490</gphoto:id><gphoto:timestamp>1321880185000</gphoto:timestamp></entry><entry><gphoto:id>5677569753823258866</gphoto:id><gphoto:timestamp>1321880197000</gphoto:timestamp></entry><entry><gphoto:id>5677569772786575762</gphoto:id><gphoto:timestamp>1321880217000</gphoto:timestamp></entry><entry><gphoto:id>5677569793580534338</gphoto:id><gphoto:timestamp>1321880229000</gphoto:timestamp></entry><entry><gphoto:id>5677569813572766594</gphoto:id><gphoto:timestamp>1321880259000</gphoto:timestamp></entry><entry><gphoto:id>5677569838368234674</gphoto:id><gphoto:timestamp>1321880275000</gphoto:timestamp></entry><entry><gphoto:id>5677569873165421890</gphoto:id><gphoto:timestamp>1321880423000</gphoto:timestamp></entry><entry><gphoto:id>5677569894754579810</gphoto:id><gphoto:timestamp>1321880438000</gphoto:timestamp></entry><entry><gphoto:id>5677569920666655794</gphoto:id><gphoto:timestamp>1321880456000</gphoto:timestamp></entry><entry><gphoto:id>5677569953023433986</gphoto:id><gphoto:timestamp>1321880609000</gphoto:timestamp></entry><entry><gphoto:id>5677569975211866754</gphoto:id><gphoto:timestamp>1321880729000</gphoto:timestamp></entry><entry><gphoto:id>5677569989539929186</gphoto:id><gphoto:timestamp>1321880748000</gphoto:timestamp></entry><entry><gphoto:id>5677570015121770610</gphoto:id><gphoto:timestamp>1321880966000</gphoto:timestamp></entry></feed>
  89.  
  90. == Get the edit link that will b needed in order to do the update on one of the photos returned in the album data
  91.  
  92. GET /data/feed/api/user/rowntreerob/albumid/5677569274306148065/photoid/5677569495943071042?fields=link[@rel="edit"] HTTP/1.1
  93. Host: picasaweb.google.com
  94. GData-Version: 2
  95. Authorization: OAuth ya29.AHES6ZSFQemR-du82WUi0R_lqJJL74_kR2HXbB6p75Q5J28
  96.  
  97.  
  98. HTTP/1.1 200 OK
  99. status: 200
  100. gdata-version: 2.0
  101. content-length: 257
  102. via: HTTP/1.1 GWA
  103. content-location: https://picasaweb.google.com/data/feed/api/user/rowntreerob/albumid/5677569274306148065/photoid/5677569495943071042?fields=link[@rel="edit"]
  104. x-content-type-options: nosniff
  105. set-cookie: _rtok=kPSn48gXeSnP; Path=/; Secure; HttpOnly, S=photos_html=8cS2J49BJYEhf4aV5_8Z4w; Domain=.google.com; Path=/; Secure; HttpOnly
  106. expires: Mon, 12 Dec 2011 18:43:53 GMT
  107. vary: Accept, X-GData-Authorization, GData-Version, Cookie
  108. x-google-cache-control: remote-fetch
  109. server: GSE
  110. last-modified: Mon, 12 Dec 2011 16:00:00 GMT
  111. x-xss-protection: 1; mode=block
  112. etag: W/"D0EEQX47eCp7ImA9WhRQF00."
  113. cache-control: private, max-age=0, must-revalidate, no-transform
  114. date: Mon, 12 Dec 2011 18:43:53 GMT
  115. x-frame-options: SAMEORIGIN
  116. content-type: application/atom+xml; charset=UTF-8; type=feed
  117. -content-encoding: gzip
  118. <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'><link rel='edit' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/rowntreerob/albumid/5677569274306148065/photoid/5677569495943071042'/></feed>
  119.  
  120. last call as json request
  121.  
  122. GET /data/feed/api/user/default/albumid/5677569274306148065/photoid/5677569495943071042?fields=link[@rel="edit"]&alt=json HTTP/1.1
  123. Host: picasaweb.google.com
  124. GData-Version: 2
  125. Authorization: OAuth ya29.AHES6ZSo--0s1tAGgpj3yfwTDj0mRrisANazdXnmTvUdfp8
  126.  
  127. HTTP/1.1 200 OK
  128. status: 200
  129. gdata-version: 2.0
  130. content-length: 263
  131. via: HTTP/1.1 GWA
  132. content-location: https://picasaweb.google.com/data/feed/api/user/default/albumid/5677569274306148065/photoid/5677569495943071042?fields=link[@rel="edit"]&alt=json
  133. x-content-type-options: nosniff
  134. set-cookie: _rtok=oOOYRM4s39zE; Path=/; Secure; HttpOnly, S=photos_html=22xA5sTTzwmbDsLJN5QofQ; Domain=.google.com; Path=/; Secure; HttpOnly
  135. expires: Tue, 13 Dec 2011 01:40:22 GMT
  136. vary: Accept, X-GData-Authorization, GData-Version, Cookie
  137. x-google-cache-control: remote-fetch
  138. -content-encoding: gzip
  139. server: GSE
  140. last-modified: Tue, 13 Dec 2011 00:00:00 GMT
  141. x-xss-protection: 1; mode=block
  142. etag: W/"DkMEQX47eCp7ImA9WhRQF04."
  143. cache-control: private, max-age=0, must-revalidate, no-transform
  144. date: Tue, 13 Dec 2011 01:40:22 GMT
  145. access-control-allow-origin: *
  146. content-type: application/json; charset=UTF-8
  147. x-frame-options: SAMEORIGIN
  148. {"version":"1.0","encoding":"UTF-8","feed":{
  149. "xmlns":"http://www.w3.org/2005/Atom","link":[{"rel":"edit","type":"application/atom+xml",
  150. "href":"https://picasaweb.google.com/data/entry/api/user/rowntreerob/albumid/5677569274306148065/photoid/5677569495943071042"}]}}
  151.  
  152. == do a partial update using the href in the above response

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.