Class: SoapyBing::OauthCredentials
- Inherits:
-
Object
- Object
- SoapyBing::OauthCredentials
- Defined in:
- lib/soapy_bing/oauth_credentials.rb
Defined Under Namespace
Classes: TokenRefreshError
Constant Summary collapse
- TOKEN_URL =
'https://login.live.com/oauth20_token.srf'
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#token_url ⇒ Object
readonly
Returns the value of attribute token_url.
Instance Method Summary collapse
- #access_token ⇒ Object
-
#initialize(oauth_options = {}) ⇒ OauthCredentials
constructor
A new instance of OauthCredentials.
Constructor Details
#initialize(oauth_options = {}) ⇒ OauthCredentials
Returns a new instance of OauthCredentials.
12 13 14 15 16 17 18 |
# File 'lib/soapy_bing/oauth_credentials.rb', line 12 def initialize( = {}) param_guard = ParamGuard.new(, env_namespace: 'BING_ADS_OAUTH') @client_id = param_guard.require!(:client_id) @client_secret = param_guard.require!(:client_secret) @refresh_token = param_guard.require!(:refresh_token) @token_url = .fetch(:token_url, ENV['BING_ADS_OAUTH_TOKEN_URL'] || TOKEN_URL) end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
10 11 12 |
# File 'lib/soapy_bing/oauth_credentials.rb', line 10 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
10 11 12 |
# File 'lib/soapy_bing/oauth_credentials.rb', line 10 def client_secret @client_secret end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
10 11 12 |
# File 'lib/soapy_bing/oauth_credentials.rb', line 10 def refresh_token @refresh_token end |
#token_url ⇒ Object (readonly)
Returns the value of attribute token_url.
10 11 12 |
# File 'lib/soapy_bing/oauth_credentials.rb', line 10 def token_url @token_url end |
Instance Method Details
#access_token ⇒ Object
20 21 22 |
# File 'lib/soapy_bing/oauth_credentials.rb', line 20 def access_token @access_token ||= request_access_token end |