poke-go-api 0.0.5 → 0.0.6

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: 0e32696b23723a8c883255b7dfe47f804a13a35e
4
- data.tar.gz: 22c041e4f1f250097d5966c2d1efe7aed450ea7c
3
+ metadata.gz: 5d6420e1aade6708df823d2b829b9373700e6e6c
4
+ data.tar.gz: d32155e58a4e2ee523ad9f2bb95918c77a60cccc
5
5
  SHA512:
6
- metadata.gz: 2f4bfdf1deb2c10f79297907393353f330354c215335a4724cac775a3bc57f1c11d0436d9c341cca6985d5ed17c59628e40058fac61cd47df80e9049d82a97b1
7
- data.tar.gz: 9d7c79886271e1a850bbecd3d843bbce16cd5edb103a0e6ea004d7f1119ccd633e482a84f3a54ed823f24b9d064db2a7b60890e0450d5733633c1f8ef2b4fd3b
6
+ metadata.gz: c27ed287d74eed85335f9015ec5707faa3001d89821ef9ad993cb7376b88c9929ccc0179e271f3ef7aa68048f12745a29f998148dfb15897d465c84f64774ce1
7
+ data.tar.gz: b74ae692e0f3e2562efa7aa34e4b8894eb4787b947a127c9d74903a172b75fee4bac9212272f9ffcad8bc59cf478cb8aebaaafaa7bda3f4c8cb9b0edaa0d0bc6
@@ -39,8 +39,12 @@ module Poke
39
39
  def perform_request(method)
40
40
  response = yield
41
41
 
42
- unless response['Token'] || response['Auth']
43
- raise Errors::GoogleAuthenticationFailure.new(method, response)
42
+ if response['Error'] == 'NeedsBrowser'
43
+ raise Errors::GoogleTwoFactorAuthenticationFailure.new(response)
44
+ else
45
+ unless response['Token'] || response['Auth']
46
+ raise Errors::GoogleAuthenticationFailure.new(method, response)
47
+ end
44
48
  end
45
49
 
46
50
  response
@@ -15,7 +15,7 @@ module Poke
15
15
 
16
16
  def login(username, password, provider)
17
17
  provider = provider.upcase
18
- raise Errors::InvalidProvider.new(provider) unless ['PTC', 'GOOGLE'].include?(provider.upcase!)
18
+ raise Errors::InvalidProvider.new(provider) unless ['PTC', 'GOOGLE'].include?(provider)
19
19
  logger.info "[+] Logging in user: #{username}"
20
20
 
21
21
  begin
@@ -31,6 +31,12 @@ module Poke
31
31
  end
32
32
  end
33
33
 
34
+ class GoogleTwoFactorAuthenticationFailure < StandardError
35
+ def initialize(response)
36
+ super("Two-factor authentication not supported. Create an app-specific password to log in.")
37
+ end
38
+ end
39
+
34
40
  class LoginFailure < StandardError
35
41
  def initialize(provider, error)
36
42
  super("Unable to login to #{provider} => [#{error} @ #{error.backtrace.first}]")
@@ -1,5 +1,5 @@
1
1
  module Poke
2
2
  module API
3
- VERSION = '0.0.5'.freeze
3
+ VERSION = '0.0.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poke-go-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nabeel Amjad