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: nil, basic_auth_password: nil, consumer_key: nil, secret_key: nil) ⇒ Client
constructor
A new instance of Client.
- #new_oauth2_client ⇒ Object
- #refresh_access_token ⇒ Object
Constructor Details
#initialize(basic_auth_username: nil, basic_auth_password: nil, consumer_key: nil, secret_key: nil) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/go_to_webinar/auth/client.rb', line 11 def initialize(basic_auth_username: nil, basic_auth_password: nil, consumer_key: nil, secret_key: nil) config = GoToWebinar::Auth.configuration @redis = Redis.new(url: config.redis_url) @basic_auth_username = config.basic_auth_username @basic_auth_password = config.basic_auth_password @consumer_key = consumer_key || config.consumer_key @secret_key = secret_key || config.secret_key @site = config.site @authorize_url = config. @authorize_optional_params = 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.
9 10 11 |
# File 'lib/go_to_webinar/auth/client.rb', line 9 def basic_auth_password @basic_auth_password end |
#basic_auth_username ⇒ Object
Returns the value of attribute basic_auth_username.
9 10 11 |
# File 'lib/go_to_webinar/auth/client.rb', line 9 def basic_auth_username @basic_auth_username end |
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
9 10 11 |
# File 'lib/go_to_webinar/auth/client.rb', line 9 def consumer_key @consumer_key end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
9 10 11 |
# File 'lib/go_to_webinar/auth/client.rb', line 9 def secret_key @secret_key end |
Instance Method Details
#access_token ⇒ Object
37 38 39 |
# File 'lib/go_to_webinar/auth/client.rb', line 37 def access_token @access_token || get_access_token_from_redis || get_new_access_token end |
#get_new_access_token ⇒ Object
41 42 43 44 45 |
# File 'lib/go_to_webinar/auth/client.rb', line 41 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
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/go_to_webinar/auth/client.rb', line 26 def new_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
47 48 49 |
# File 'lib/go_to_webinar/auth/client.rb', line 47 def refresh_access_token @access_token = access_token&.refresh! end |