@@ -72,6 +72,10 @@ class Configuration
7272 # Defines the access token (Bearer) used with OAuth2.
7373 attr_accessor :access_token
7474
75+ # Defines the URL used to obtain access tokens (Bearer) used with OAuth2.
76+ # @return [String]
77+ attr_accessor :access_token_url
78+
7579 # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
7680 # Overrides the access_token if set
7781 # @return [Proc]
@@ -193,16 +197,16 @@ def initialize
193197 @force_ending_format = false
194198 @logger = defined? ( Rails ) ? Rails . logger : Logger . new ( STDOUT )
195199 @access_token_expiration = nil
200+ @access_token_url = 'https://api.bandwidth.com/api/v1/oauth2/token'
196201 @access_token_getter = Proc . new {
197202 access_token_valid = @access_token && ( @access_token_expiration . nil? || @access_token_expiration > Time . now + 60 )
198203 next @access_token if access_token_valid
199204 next unless @client_id && @client_secret
200205
201206 puts "Refreshing access token..." if @debugging
202207 # obtain new access token using client credentials
203- token_url = 'https://api.bandwidth.com/api/v1/oauth2/token'
204208 auth_header = 'Basic ' + [ "#{ @client_id } :#{ @client_secret } " ] . pack ( 'm' ) . delete ( "\r \n " )
205- conn = Faraday . new ( url : token_url ) do |faraday |
209+ conn = Faraday . new ( url : @access_token_url ) do |faraday |
206210 faraday . request :url_encoded
207211 faraday . adapter Faraday . default_adapter
208212 end
0 commit comments