picasa 0.7.5 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a919f287a26d11d7377d530bd7d63463f8d4e66d
4
- data.tar.gz: 685f7dd9e7e0501cd01c135bc3255e170f553a14
3
+ metadata.gz: 91a09cb41c7e4e13eb830c390c2cac41ec9bc159
4
+ data.tar.gz: 25ab483fc8fbe5ef7095ed336b991b19ca01830d
5
5
  SHA512:
6
- metadata.gz: b1c329012564890cd7354f63df9e10fc29559c546fe9465bca55ed438b22c45c6008fa2279d7b16e6f3690399e853eed4daf47bac860cf4ab279a7ee6f78e665
7
- data.tar.gz: 8e86bea1f9ce94b379886efdab037cdcb8eb6aac19f07164e613ee29dddb42a189a9618e66d645b0042145ba0e752a62f0c80e3497af2c5965e8f408e8134773
6
+ metadata.gz: b11f16ab4af155c874d5511eeb0ab4787720cff01639ada8508f93591a14a1318102e683adc74b446ad0519ae9bfc24c89825ec3638d74db88b6cb06336b04c9
7
+ data.tar.gz: 5f8638b15e131fa0109f08bdcda0ad4c7ffe53a34acbcbd032172b193ae7ff99e04daef20965e2166ef1d6171275cad64bc277ffa08cfa700c02c7ae55a7f178
data/README.md CHANGED
@@ -28,17 +28,23 @@ client.photo.create("album_id", file_path: "path/to/my-photo.png")
28
28
 
29
29
  When request is authenticated, response will contain private data, however this can be controlled by `access` parameter.
30
30
 
31
- You can authenticate by specifing password:
31
+ You can authenticate by specifing access_token:
32
32
 
33
33
  ```ruby
34
- client = Picasa::Client.new(user_id: "some.user@gmail.com", password: "secret")
34
+ client = Picasa::Client.new(user_id: "some.user@gmail.com", access_token: "access-token")
35
35
  ```
36
36
 
37
- Or by setting custom authorization header, i.e. taken from [OAuth](https://developers.google.com/accounts/docs/OAuth2) authentication (your secret access token after "Bearer" or "OAuth" words):
37
+ As authenticating by providing password is no longer possible due to google API shutdown https://developers.google.com/accounts/docs/AuthForInstalledApps
38
+ you need to set `access_token` for authenticated requests.
38
39
 
39
- ```ruby
40
- client = Picasa::Client.new(user_id: "some.user@gmail.com", authorization_header: "Bearer <access-token>")
41
- ```
40
+ For one time usage, you can retrieve access_token from google playground:
41
+ * Visit https://developers.google.com/oauthplayground
42
+ * Find "Picasa Web v2"
43
+ * Click "Authorize APIs" providing your credentials
44
+ * Click "Exchange authorization code for tokens"
45
+ * Copy `access_token` value
46
+
47
+ OAuth2 integration is not yet supported in this gem.
42
48
 
43
49
  ### Proxy
44
50
 
@@ -61,15 +67,13 @@ thor update imagery
61
67
  And then use it (it will create album taking title from folder name and upload all photos from that directory):
62
68
 
63
69
  ```
64
- GOOGLE_USER_ID=your.email@gmail.com GOOGLE_PASSWORD=secret thor imagery:upload path-to-folder-with-photos
65
- # Without specifing password
66
- GOOGLE_USER_ID=your.email@gmail.com GOOGLE_AUTHORIZATION_HEADER="GoogleLogin auth=token" thor imagery:upload path-to-folder-with-photos
70
+ GOOGLE_USER_ID=your.email@gmail.com GOOGLE_ACCESS_TOKEN=access-token thor imagery:upload path-to-folder-with-photos
67
71
  ```
68
72
 
69
73
  If your upload was somehow interrupted, you can resume it by adding `--continue` option:
70
74
 
71
75
  ```
72
- GOOGLE_USER_ID=your.email@gmail.com GOOGLE_PASSWORD=secret thor imagery:upload --continue path-to-folder-with-photos
76
+ GOOGLE_USER_ID=your.email@gmail.com GOOGLE_ACCESS_TOKEN=access-token thor imagery:upload --continue path-to-folder-with-photos
73
77
  ```
74
78
 
75
79
  If you run out of quota and want to resize images to fit Picasa free storage limits, you can install `rmagick` gem and run (this will modify files):
@@ -78,15 +78,16 @@ class Imagery < Thor
78
78
 
79
79
  no_tasks do
80
80
  def client
81
- @client ||= Picasa::Client.new(user_id: ENV["GOOGLE_USER_ID"],
82
- authorization_header: ENV["GOOGLE_AUTHORIZATION_HEADER"],
83
- password: ENV["GOOGLE_PASSWORD"])
81
+ @client ||= Picasa::Client.new(
82
+ user_id: ENV["GOOGLE_USER_ID"],
83
+ access_token: ENV["GOOGLE_ACCESS_TOKEN"]
84
+ )
84
85
  end
85
86
 
86
87
  def require_credentials
87
88
  say "You must specify GOOGLE_USER_ID env variable" and exit if ENV["GOOGLE_USER_ID"].nil?
88
- if ENV["GOOGLE_AUTHORIZATION_HEADER"].nil? && ENV["GOOGLE_PASSWORD"].nil?
89
- say "You must specify GOOGLE_PASSWORD or GOOGLE_AUTHORIZATION_HEADER env variable" and exit
89
+ if ENV["GOOGLE_ACCESS_TOKEN"].nil?
90
+ say "You must specify GOOGLE_ACCESS_TOKEN env variable" and exit
90
91
  end
91
92
  end
92
93
 
@@ -1,19 +1,26 @@
1
1
  module Picasa
2
2
  module API
3
3
  class Base
4
- attr_reader :user_id, :authorization_header
4
+ attr_reader :user_id, :authorization_header, :access_token
5
5
 
6
6
  # @param [Hash] credentials
7
7
  # @option credentials [String] :user_id google username/email
8
- # @option credentials [String] :authorization_header header for authenticating requests
8
+ # @option credentials [String] :access_token token for authorizing requests
9
9
  def initialize(credentials = {})
10
10
  @user_id = credentials.fetch(:user_id)
11
+ @access_token = credentials[:access_token]
11
12
  @authorization_header = credentials[:authorization_header]
12
13
  end
13
14
 
14
15
  def auth_header
15
16
  {}.tap do |header|
16
- header["Authorization"] = authorization_header if authorization_header
17
+ token = if access_token
18
+ "Bearer #{access_token}"
19
+ elsif authorization_header
20
+ authorization_header
21
+ end
22
+
23
+ header["Authorization"] = token if token
17
24
  end
18
25
  end
19
26
  end
@@ -1,15 +1,21 @@
1
1
  module Picasa
2
2
  class Client
3
3
  attr_reader :user_id
4
- attr_accessor :password, :authorization_header
4
+ attr_accessor :access_token, :authorization_header
5
5
 
6
6
  # @param [Hash] credentials
7
7
  # @option credentials [String] :user_id google username/email
8
- # @option credentials [String] :password password for given username/email
9
8
  # @option credentials [String] :authorization_header custom authorization header (i.e. taken from OAuth2)
9
+ # @option credentials [String] :access_token picasa OAuth2 access token
10
10
  def initialize(credentials = {})
11
- @user_id = credentials[:user_id] || raise(ArgumentError, "You must specify user_id")
12
- @password = credentials[:password]
11
+ if credentials[:password]
12
+ raise(ArgumentError, "Providing password has no effect as google login by password API is not active anymore https://developers.google.com/accounts/docs/AuthForInstalledApps")
13
+ end
14
+ @user_id = credentials[:user_id] || raise(ArgumentError, "You must specify user_id")
15
+ @access_token = credentials[:access_token]
16
+ if credentials[:authorization_header]
17
+ puts "Passing authorization_header is deprecated. Please pass access_token"
18
+ end
13
19
  @authorization_header = credentials[:authorization_header]
14
20
  end
15
21
 
@@ -21,7 +27,6 @@ module Picasa
21
27
  # album_list.title
22
28
  # # => "My album"
23
29
  def album
24
- authenticate if authenticates?
25
30
  API::Album.new(credentials)
26
31
  end
27
32
 
@@ -33,7 +38,6 @@ module Picasa
33
38
  # photo.id
34
39
  # # => "4322232322421"
35
40
  def photo
36
- authenticate if authenticates?
37
41
  API::Photo.new(credentials)
38
42
  end
39
43
 
@@ -45,7 +49,6 @@ module Picasa
45
49
  # tag_list.title
46
50
  # # => "holidays"
47
51
  def tag
48
- authenticate if authenticates?
49
52
  API::Tag.new(credentials)
50
53
  end
51
54
 
@@ -57,45 +60,16 @@ module Picasa
57
60
  # comment_list.entries.map &:content
58
61
  # # => "nice photo!"
59
62
  def comment
60
- authenticate if authenticates?
61
63
  API::Comment.new(credentials)
62
64
  end
63
65
 
64
- # @return [String]
65
- def authenticate
66
- response = Connection.new.post(
67
- host: HTTP::API_AUTH_URL,
68
- headers: {"Content-Type" => "application/x-www-form-urlencoded"},
69
- path: "/accounts/ClientLogin",
70
- body: Utils.inline_query(
71
- "accountType" => "HOSTED_OR_GOOGLE",
72
- "Email" => user_id,
73
- "Passwd" => password,
74
- "service" => "lh2",
75
- "source" => "ruby-gem-picasa-v#{VERSION}"
76
- )
77
- )
78
-
79
- key = extract_auth_key(response.body)
80
- @authorization_header = "GoogleLogin auth=#{key}"
81
- end
82
-
83
66
  private
84
67
 
85
- def authenticates?
86
- password && authorization_header.nil?
87
- end
88
-
89
68
  def credentials
90
69
  {user_id: user_id}.tap do |credentials|
70
+ credentials[:access_token] = access_token if access_token
91
71
  credentials[:authorization_header] = authorization_header if authorization_header
92
72
  end
93
73
  end
94
-
95
- def extract_auth_key(data)
96
- response = data.split("\n").map { |v| v.split("=") }
97
- params = Hash[response]
98
- params["Auth"]
99
- end
100
74
  end
101
75
  end
@@ -1,3 +1,3 @@
1
1
  module Picasa
2
- VERSION = "0.7.5"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "webmock"
29
29
  spec.add_development_dependency "mocha", ">= 0.13.0"
30
30
  spec.add_development_dependency "vcr", ">= 2.4.0"
31
+
32
+ spec.post_install_message = "Authenticating by providing password is no longer possible due to google API shutdown https://developers.google.com/accounts/docs/AuthForInstalledApps You need to set `access_token` for authenticated requests now."
31
33
  end
@@ -7,43 +7,16 @@ describe Picasa::Client do
7
7
  end
8
8
  end
9
9
 
10
- it "allows to assign custom authorization header" do
11
- client = Picasa::Client.new(:user_id => "john.doe", :authorization_header => "OAuth token")
12
- assert_equal "OAuth token", client.authorization_header
13
- end
14
-
15
- it "allows to set password on instance" do
16
- client = Picasa::Client.new(:user_id => "john.doe", :password => "unknown")
17
- client.password = "secret"
18
-
19
- assert_equal "secret", client.password
10
+ it "raises ArgumentError when providing password" do
11
+ assert_raises(Picasa::ArgumentError) do
12
+ client = Picasa::Client.new(:user_id => "john.doe", :password => "unknown")
13
+ end
20
14
  end
21
15
 
22
- it "allows to set authorization_header on instance" do
16
+ it "allows to set access_token on instance" do
23
17
  client = Picasa::Client.new(:user_id => "john.doe")
24
- client.authorization_header = "Bearer some-token"
25
-
26
- assert_equal "Bearer some-token", client.authorization_header
27
- end
18
+ client.access_token = "some-access-token"
28
19
 
29
- describe "#authenticate" do
30
- it "successfully authenticates" do
31
- VCR.use_cassette("auth-success") do
32
- client = Picasa::Client.new(:user_id => "w.wnetrzak@gmail.com", :password => Password)
33
- client.authenticate
34
-
35
- refute_nil client.authorization_header
36
- end
37
- end
38
-
39
- it "raises an ForbiddenError when authentication failed" do
40
- VCR.use_cassette("auth-failed") do
41
- client = Picasa::Client.new(:user_id => "w.wnetrzak@gmail.com", :password => "invalid")
42
-
43
- assert_raises(Picasa::ForbiddenError) do
44
- client.authenticate
45
- end
46
- end
47
- end
20
+ assert_equal "some-access-token", client.access_token
48
21
  end
49
22
  end
@@ -9,8 +9,7 @@ require "mocha/setup"
9
9
 
10
10
  require "picasa"
11
11
 
12
- AuthHeader = ENV["PICASA_AUTH_HEADER"] || "GoogleLogin auth=token"
13
- Password = ENV["PICASA_PASSWORD"] || "secret"
12
+ AuthHeader = ENV["PICASA_ACCESS_TOKEN"] || "GoogleLogin auth=token"
14
13
 
15
14
  MultiJson.adapter = ENV["JSON_PARSER"] || "oj"
16
15
 
@@ -19,7 +18,6 @@ VCR.configure do |c|
19
18
  c.hook_into :webmock
20
19
  c.default_cassette_options = {preserve_exact_body_bytes: true}
21
20
  c.filter_sensitive_data("<FILTERED>") { AuthHeader }
22
- c.filter_sensitive_data("<FILTERED>") { Password }
23
21
  end
24
22
 
25
23
  class MiniTest::Test
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picasa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojciech Wnętrzak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -176,8 +176,6 @@ files:
176
176
  - test/cassettes/album-list.yml
177
177
  - test/cassettes/album-show.yml
178
178
  - test/cassettes/album-update.yml
179
- - test/cassettes/auth-failed.yml
180
- - test/cassettes/auth-success.yml
181
179
  - test/cassettes/comment-400.yml
182
180
  - test/cassettes/comment-create.yml
183
181
  - test/cassettes/comment-destroy.yml
@@ -205,7 +203,9 @@ homepage: https://github.com/morgoth/picasa
205
203
  licenses:
206
204
  - MIT
207
205
  metadata: {}
208
- post_install_message:
206
+ post_install_message: Authenticating by providing password is no longer possible due
207
+ to google API shutdown https://developers.google.com/accounts/docs/AuthForInstalledApps
208
+ You need to set `access_token` for authenticated requests now.
209
209
  rdoc_options: []
210
210
  require_paths:
211
211
  - lib
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 2.4.5
224
+ rubygems_version: 2.4.7
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: Simple Google Picasa managment
@@ -238,8 +238,6 @@ test_files:
238
238
  - test/cassettes/album-list.yml
239
239
  - test/cassettes/album-show.yml
240
240
  - test/cassettes/album-update.yml
241
- - test/cassettes/auth-failed.yml
242
- - test/cassettes/auth-success.yml
243
241
  - test/cassettes/comment-400.yml
244
242
  - test/cassettes/comment-create.yml
245
243
  - test/cassettes/comment-destroy.yml
@@ -1,50 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://www.google.com/accounts/ClientLogin?alt=json
6
- body:
7
- encoding: US-ASCII
8
- string: accountType=HOSTED_OR_GOOGLE&Email=w.wnetrzak%40gmail.com&Passwd=invalid&service=lh2&source=ruby-gem-picasa-v0.5.4
9
- headers:
10
- User-Agent:
11
- - ruby-gem-picasa-v0.5.4 (gzip)
12
- Gdata-Version:
13
- - "2"
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- Accept-Encoding:
17
- - gzip, deflate
18
- response:
19
- status:
20
- code: 403
21
- message: Forbidden
22
- headers:
23
- Content-Type:
24
- - text/plain
25
- Cache-Control:
26
- - no-cache, no-store
27
- Pragma:
28
- - no-cache
29
- Expires:
30
- - Mon, 01-Jan-1990 00:00:00 GMT
31
- Content-Encoding:
32
- - gzip
33
- Date:
34
- - Thu, 01 Nov 2012 19:20:53 GMT
35
- X-Content-Type-Options:
36
- - nosniff
37
- X-Xss-Protection:
38
- - 1; mode=block
39
- Content-Length:
40
- - "44"
41
- Server:
42
- - GSE
43
- body:
44
- encoding: ASCII-8BIT
45
- string: !binary |
46
- H4sIAAAAAAAAAHMtKsovsnVKTHEsLclIzSvJTE4syczP4wIAm+kHYxgAAAA=
47
-
48
- http_version:
49
- recorded_at: Thu, 01 Nov 2012 19:20:52 GMT
50
- recorded_with: VCR 2.3.0
@@ -1,64 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://www.google.com/accounts/ClientLogin?alt=json
6
- body:
7
- encoding: US-ASCII
8
- string: accountType=HOSTED_OR_GOOGLE&Email=w.wnetrzak%40gmail.com&Passwd=<FILTERED>&service=lh2&source=ruby-gem-picasa-v0.5.4
9
- headers:
10
- User-Agent:
11
- - ruby-gem-picasa-v0.5.4 (gzip)
12
- Gdata-Version:
13
- - "2"
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- Accept-Encoding:
17
- - gzip, deflate
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Content-Type:
24
- - text/plain
25
- Cache-Control:
26
- - no-cache, no-store
27
- Pragma:
28
- - no-cache
29
- Expires:
30
- - Mon, 01-Jan-1990 00:00:00 GMT
31
- Content-Encoding:
32
- - gzip
33
- Date:
34
- - Thu, 01 Nov 2012 19:19:34 GMT
35
- X-Content-Type-Options:
36
- - nosniff
37
- X-Xss-Protection:
38
- - 1; mode=block
39
- Content-Length:
40
- - "666"
41
- Server:
42
- - GSE
43
- body:
44
- encoding: ASCII-8BIT
45
- string: !binary |
46
- H4sIAAAAAAAAAK3St66jWgCF4f68iyVyKKYANjmYZNimsUzYZAMm8/Rziqv7
47
- BNP87ZI+rUAHf4AnCILd/kYic1rbyfyS6A4Gd/AF4fEZRiNWzbmoyxD35se+
48
- Tr6oXwTvOF4Rc7c2n8OkWeK67U29Mg2puiK9Z+U1Hr4ET3lYRaaL6XO7vJED
49
- 8jjXlcwwWq+3H+sZGJCCFNwP9Vx7Y1/homjQ7D7vJMoQScXL0r9lwhuwTTOC
50
- 19dZFygM2a5bO9xaCqJ83QcItHtxDJmphqoIzT0/Ef4AsqXZncAs72adI9We
51
- nL3uqWTmoMxYyAOf3+3XqQq7eJ5lOA62bC1kyXGNM7oMmMxsCBzLqjbi5Enl
52
- xwr+V9p/AxwDsgWS3kqbD9B81p1sEhGF8Q5CRPn0Xbyq1rkaqYtfcE1K6XOo
53
- aSM+DyxOEfup1Ra77kYHJ9nqqvQL86lvqYi8P676powaN08s2xb0ntakorfx
54
- Xlzrl+E6LHY8tagNkDmgPIFbNN5Ci9WEwW6aki2bVMvsLBybSrcIpaN7ylGC
55
- 6JcUimuzCZ1nbDd/PskXrKI90xS+oJ32Ghl11wJgUgPT26MrtTBZDCW4LxnQ
56
- UiQICnWeppndO2s6gvqc7VMjbHrFko/4zC0Ky+1L1/Q8nqkfYV2q/5Tmf6Fk
57
- 2RXW+tv+TjemIGitDHDlWtErQxS3DXgeEPl47ChAQZPJAZ5e0gWJV+ffOq2G
58
- BvV6Ugfj8HMbsXNsHK9IdycCY52BThF5jy2YqQ1gxMc26sZu8WncGw/a/72y
59
- SDKSkLOAIWDPhX5ZQj53hHZiybChK6f4yGQs04Lw9ofG4A33e4v7R2qmIXng
60
- 65ZWDzphm0pXmX6/gsgPnkKjyH4mQVt6cj9/Ad+8nchxAwAA
61
-
62
- http_version:
63
- recorded_at: Thu, 01 Nov 2012 19:19:33 GMT
64
- recorded_with: VCR 2.3.0