go_to_webinar 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/go_to_webinar/auth/client.rb +12 -8
- data/lib/go_to_webinar/client.rb +1 -1
- data/lib/go_to_webinar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5382c5f098cb5115ef8b73097a267e7ad0525ca74426fb7b3dce8913ae3a5f13
|
4
|
+
data.tar.gz: 486d53cc45226b5870009bbab44176a0dfbdcbda1f106772c7a8713a6ef4745e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5524d982a537735b73ea4f6d71c7a60c4430ec6556417b4fa6ad60bdd52091bbde468ef6bccb8e3adb9f767147e221daeee8a87f471a9a269b88b120cd3148
|
7
|
+
data.tar.gz: 542eba8c96367c9fb30531e54928eb26f75f4b9ce97f8657c33cfb5e127108d478ff078fed300896b20dc4cb83bb8ce1e554a56ff8ae7383cf933f1c817d44ea
|
@@ -9,19 +9,20 @@ module GoToWebinar
|
|
9
9
|
def initialize(basic_auth_username: nil, basic_auth_password: nil, consumer_key: nil, secret_key: nil)
|
10
10
|
config = GoToWebinar::Auth.configuration
|
11
11
|
@redis = Redis.new(url: config.redis_url)
|
12
|
-
@basic_auth_username =
|
13
|
-
@basic_auth_password =
|
12
|
+
@basic_auth_username = config.basic_auth_username
|
13
|
+
@basic_auth_password = config.basic_auth_password
|
14
14
|
@consumer_key = consumer_key || config.consumer_key
|
15
15
|
@secret_key = secret_key || config.secret_key
|
16
16
|
@site = config.site
|
17
17
|
@authorize_url = config.authorize_url
|
18
|
+
@authorize_optional_params = config.authorize_optional_params
|
18
19
|
@token_url = config.token_url
|
19
20
|
@auth_scheme = config.auth_scheme
|
20
21
|
@oauth2_client = new_oauth2_client
|
21
22
|
end
|
22
23
|
|
23
24
|
def new_oauth2_client
|
24
|
-
|
25
|
+
OAuth2::Client.new(
|
25
26
|
consumer_key,
|
26
27
|
secret_key,
|
27
28
|
site: site,
|
@@ -47,7 +48,7 @@ module GoToWebinar
|
|
47
48
|
|
48
49
|
private
|
49
50
|
|
50
|
-
attr_accessor :redis, :site, :authorize_url, :
|
51
|
+
attr_accessor :redis, :site, :authorize_url, :authorize_optional_params
|
51
52
|
attr_accessor :token_url, :auth_scheme, :oauth2_client
|
52
53
|
|
53
54
|
def get_access_token_from_redis(redis_key: 'g2w_access_token')
|
@@ -56,7 +57,10 @@ module GoToWebinar
|
|
56
57
|
token_hash = JSON.parse(token_json)&.[]("token") if token_json
|
57
58
|
@access_token = OAuth2::AccessToken.from_hash(oauth2_client, token_hash) if token_hash
|
58
59
|
|
59
|
-
# if we found it redis, let's
|
60
|
+
# if we found it in redis, and it's expired, let's just refresh it
|
61
|
+
@access_token = refresh_access_token if @access_token&.expired?
|
62
|
+
|
63
|
+
# let's return it if we got it =)
|
60
64
|
return @access_token if @access_token
|
61
65
|
|
62
66
|
# if it doesn't currently exist in redis, return nil
|
@@ -72,18 +76,18 @@ module GoToWebinar
|
|
72
76
|
consumer_key,
|
73
77
|
secret_key,
|
74
78
|
site: site,
|
75
|
-
authorize_url:
|
79
|
+
authorize_url: authorize_url_with_params,
|
76
80
|
token_url: token_url,
|
77
81
|
auth_scheme: auth_scheme
|
78
82
|
)
|
79
83
|
end
|
80
84
|
|
81
|
-
def
|
85
|
+
def authorize_url_with_params
|
82
86
|
authorize_url + '?' + authorize_url_params
|
83
87
|
end
|
84
88
|
|
85
89
|
def authorize_url_params
|
86
|
-
URI.encode_www_form({client_id: consumer_key}.merge(
|
90
|
+
URI.encode_www_form({client_id: consumer_key}.merge(authorize_optional_params))
|
87
91
|
end
|
88
92
|
end
|
89
93
|
end
|
data/lib/go_to_webinar/client.rb
CHANGED
@@ -45,7 +45,7 @@ module GoToWebinar
|
|
45
45
|
retries ||= 0
|
46
46
|
yield
|
47
47
|
rescue RestClient::Forbidden => exception
|
48
|
-
raise unless (
|
48
|
+
raise unless (retries += 1) < 2
|
49
49
|
raise unless int_error_code(exception) == "InvalidToken"
|
50
50
|
raise unless @access_token&.expired?
|
51
51
|
|