yt 0.25.14 → 0.25.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66746428c5b4ed1341662d4266f61e4c4bccab20
4
- data.tar.gz: 4632fc9ca52c942064c011087ce25ddb0d7c2f79
3
+ metadata.gz: 9911269f376cd2e904f6ac1137b709a0d0de982f
4
+ data.tar.gz: 2aeff7eae2cf2506a89f98f6b034f05155f5802b
5
5
  SHA512:
6
- metadata.gz: 5f1af5640f45285d6c85f62af0831fc56216d21e5ef9fbe9a972434730bc27c2a121dd470ebdb0b44305ba91e0869b352b36fc19a43ac2fadd5cd0148cd97483
7
- data.tar.gz: 23ee7315bea131dc9bf7ef5aaf851c080babfedc98e16e67bf04453b45545c4b0fc21d63039f488cde28af63e89c4d6038a63ca3b4f751b8c570ba30396b50cb
6
+ metadata.gz: 014afb4485d06e6b967c56c623cea923bfcb3cc7981a3084863226f82d8868a3b3fca455a7c3308148111cac0f55bdde51865f234b37bd7df7eb3c8a4eaac66b
7
+ data.tar.gz: 770116f76d5b33c0e1e610118074f3e840a6060aee5ec5ca7b332012f08d61d7e738c99f33ad8888d3d73c780efc7ba4d093672d342c628809f3e95c971beb63
@@ -6,6 +6,10 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.25.15 - 2015-12-17
10
+
11
+ * [FEATURE] Add `revoke_access` to Yt::Account
12
+
9
13
  ## 0.25.14 - 2015-12-16
10
14
 
11
15
  * [ENHANCEMENT] Add `:display_name` to each content owner returned by account.content_owners
@@ -9,6 +9,7 @@ module Yt
9
9
  def has_authentication
10
10
  require 'yt/collections/authentications'
11
11
  require 'yt/collections/device_flows'
12
+ require 'yt/collections/revocations'
12
13
  require 'yt/errors/missing_auth'
13
14
  require 'yt/errors/no_items'
14
15
  require 'yt/errors/unauthorized'
@@ -60,6 +61,18 @@ module Yt
60
61
  old_access_token != authentication.access_token
61
62
  end
62
63
 
64
+ # Revoke access given to the application.
65
+ # Returns true if the access was correctly revoked.
66
+ # @see https://developers.google.com/identity/protocols/OAuth2WebServer#tokenrevoke
67
+ def revoke_access
68
+ revocations.first!
69
+ @authentication = @access_token = @refreshed_authentications = nil
70
+ true
71
+ rescue Errors::RequestError => e
72
+ raise unless e.reasons.include? 'invalid_token'
73
+ false
74
+ end
75
+
63
76
  private
64
77
 
65
78
  def current_authentication
@@ -150,6 +163,12 @@ module Yt
150
163
  end
151
164
  end
152
165
 
166
+ def revocations
167
+ @revocations ||= Collections::Revocations.of(self).tap do |auth|
168
+ auth.auth_params = {token: @refresh_token || @access_token}
169
+ end
170
+ end
171
+
153
172
  def authentication_url_params
154
173
  {}.tap do |params|
155
174
  params[:client_id] = client_id
@@ -0,0 +1,30 @@
1
+ require 'yt/collections/authentications'
2
+ require 'yt/models/revocation'
3
+
4
+ module Yt
5
+ module Collections
6
+ class Revocations < Authentications
7
+ attr_accessor :auth_params
8
+
9
+ private
10
+
11
+ # This overrides the parent mehthod defined in Authentications
12
+ def attributes_for_new_item(data)
13
+ {data: data}
14
+ end
15
+
16
+ def list_params
17
+ super.tap do |params|
18
+ params[:host] = 'accounts.google.com'
19
+ params[:path] = '/o/oauth2/revoke'
20
+ params[:request_format] = nil
21
+ params[:method] = :get
22
+ params[:auth] = nil
23
+ params[:body] = nil
24
+ params[:camelize_body] = false
25
+ params[:params] = auth_params
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ require 'yt/models/base'
2
+
3
+ module Yt
4
+ module Models
5
+ # @private
6
+ class Revocation < Base
7
+ def initialize(options = {})
8
+ @data = options[:data]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.25.14'
2
+ VERSION = '0.25.15'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.14
4
+ version: 0.25.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -156,6 +156,7 @@ files:
156
156
  - lib/yt/collections/reports.rb
157
157
  - lib/yt/collections/resources.rb
158
158
  - lib/yt/collections/resumable_sessions.rb
159
+ - lib/yt/collections/revocations.rb
159
160
  - lib/yt/collections/snippets.rb
160
161
  - lib/yt/collections/statistics_sets.rb
161
162
  - lib/yt/collections/statuses.rb
@@ -205,6 +206,7 @@ files:
205
206
  - lib/yt/models/reference.rb
206
207
  - lib/yt/models/resource.rb
207
208
  - lib/yt/models/resumable_session.rb
209
+ - lib/yt/models/revocation.rb
208
210
  - lib/yt/models/right_owner.rb
209
211
  - lib/yt/models/snippet.rb
210
212
  - lib/yt/models/statistics_set.rb