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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 030fc9f7cfb6d2822a0f5b5a256d6d331fcac1ddfdf8b58638e6955f19136f4a
4
- data.tar.gz: 3f412135c3e04ad4b05933428bcbb66c50a52514ae8dddc6f01114f2b4299309
3
+ metadata.gz: 5382c5f098cb5115ef8b73097a267e7ad0525ca74426fb7b3dce8913ae3a5f13
4
+ data.tar.gz: 486d53cc45226b5870009bbab44176a0dfbdcbda1f106772c7a8713a6ef4745e
5
5
  SHA512:
6
- metadata.gz: 93997131e929a036bf5d3da5d9b87cbfbbea7927c067504637a76747cc03735096def75cab82aeaf3c53f2ac27c63a4299ea05b6a65e3e636157cdf8b2cc279e
7
- data.tar.gz: d9bb3ae9dc2ee6128d06eddd1c1bea5446108e3be17674bfb4f36aa1db3033bc077a55a150f1adc4e41f41db0623130305a404bf36dd4913f06e38a486bef634
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 = basic_auth_username || config.basic_auth_username
13
- @basic_auth_password = basic_auth_password || config.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
- oauth2_client = OAuth2::Client.new(
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, :authorize_url_optional_params
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 return it
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: 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 authorize_url
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(authorize_url_optional_params))
90
+ URI.encode_www_form({client_id: consumer_key}.merge(authorize_optional_params))
87
91
  end
88
92
  end
89
93
  end
@@ -45,7 +45,7 @@ module GoToWebinar
45
45
  retries ||= 0
46
46
  yield
47
47
  rescue RestClient::Forbidden => exception
48
- raise unless (retires += 1) < 2
48
+ raise unless (retries += 1) < 2
49
49
  raise unless int_error_code(exception) == "InvalidToken"
50
50
  raise unless @access_token&.expired?
51
51
 
@@ -1,3 +1,3 @@
1
1
  module GoToWebinar
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_to_webinar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Jeremias da Silva