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 +4 -4
- data/lib/poke-api/auth/google.rb +6 -2
- data/lib/poke-api/client.rb +1 -1
- data/lib/poke-api/errors.rb +6 -0
- data/lib/poke-api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d6420e1aade6708df823d2b829b9373700e6e6c
|
4
|
+
data.tar.gz: d32155e58a4e2ee523ad9f2bb95918c77a60cccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c27ed287d74eed85335f9015ec5707faa3001d89821ef9ad993cb7376b88c9929ccc0179e271f3ef7aa68048f12745a29f998148dfb15897d465c84f64774ce1
|
7
|
+
data.tar.gz: b74ae692e0f3e2562efa7aa34e4b8894eb4787b947a127c9d74903a172b75fee4bac9212272f9ffcad8bc59cf478cb8aebaaafaa7bda3f4c8cb9b0edaa0d0bc6
|
data/lib/poke-api/auth/google.rb
CHANGED
@@ -39,8 +39,12 @@ module Poke
|
|
39
39
|
def perform_request(method)
|
40
40
|
response = yield
|
41
41
|
|
42
|
-
|
43
|
-
raise Errors::
|
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
|
data/lib/poke-api/client.rb
CHANGED
@@ -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
|
18
|
+
raise Errors::InvalidProvider.new(provider) unless ['PTC', 'GOOGLE'].include?(provider)
|
19
19
|
logger.info "[+] Logging in user: #{username}"
|
20
20
|
|
21
21
|
begin
|
data/lib/poke-api/errors.rb
CHANGED
@@ -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}]")
|
data/lib/poke-api/version.rb
CHANGED