Class: GoToWebinar::Auth::Client
- Inherits:
-
Object
- Object
- GoToWebinar::Auth::Client
- Defined in:
- lib/go_to_webinar/auth/client.rb
Instance Attribute Summary collapse
-
#basic_auth_password ⇒ Object
Returns the value of attribute basic_auth_password.
-
#basic_auth_username ⇒ Object
Returns the value of attribute basic_auth_username.
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
Instance Method Summary collapse
- #access_token ⇒ Object
- #get_new_access_token ⇒ Object
-
#initialize(basic_auth_username:, basic_auth_password:, consumer_key:, secret_key:) ⇒ Client
constructor
A new instance of Client.
- #new_oauth2_client ⇒ Object
- #refresh_access_token ⇒ Object
Constructor Details
#initialize(basic_auth_username:, basic_auth_password:, consumer_key:, secret_key:) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/go_to_webinar/auth/client.rb', line 8 def initialize(basic_auth_username:, basic_auth_password:, consumer_key:, secret_key:) config = GoToWebinar::Auth.configuration @redis = Redis.new(url: config.redis_url) @basic_auth_username = basic_auth_username || config.basic_auth_username @basic_auth_password = basic_auth_password || config.basic_auth_password @consumer_key = consumer_key || config.consumer_key @secret_key = secret_key || config.secret_key @site = config.site = config. @token_url = config.token_url @auth_scheme = config.auth_scheme @oauth2_client = new_oauth2_client end |
Instance Attribute Details
#basic_auth_password ⇒ Object
Returns the value of attribute basic_auth_password.
6 7 8 |
# File 'lib/go_to_webinar/auth/client.rb', line 6 def basic_auth_password @basic_auth_password end |
#basic_auth_username ⇒ Object
Returns the value of attribute basic_auth_username.
6 7 8 |
# File 'lib/go_to_webinar/auth/client.rb', line 6 def basic_auth_username @basic_auth_username end |
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
6 7 8 |
# File 'lib/go_to_webinar/auth/client.rb', line 6 def consumer_key @consumer_key end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
6 7 8 |
# File 'lib/go_to_webinar/auth/client.rb', line 6 def secret_key @secret_key end |
Instance Method Details
#access_token ⇒ Object
33 34 35 |
# File 'lib/go_to_webinar/auth/client.rb', line 33 def access_token @access_token || get_access_token_from_redis || get_new_access_token end |
#get_new_access_token ⇒ Object
37 38 39 40 41 |
# File 'lib/go_to_webinar/auth/client.rb', line 37 def get_new_access_token token = oauth2_client.password.get_token(basic_auth_username, basic_auth_password) save_to_redis(token) @access_token = token end |
#new_oauth2_client ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/go_to_webinar/auth/client.rb', line 22 def new_oauth2_client oauth2_client = OAuth2::Client.new( consumer_key, secret_key, site: site, authorize_url: , token_url: token_url, auth_scheme: auth_scheme ) end |
#refresh_access_token ⇒ Object
43 44 45 |
# File 'lib/go_to_webinar/auth/client.rb', line 43 def refresh_access_token @access_token = access_token&.refresh! end |