lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.62 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.63

- old
+ new

@@ -23,10 +23,14 @@ end # Will create access_token method based on passed parameters def oauth2(client_id: nil, client_secret: nil, token_url: nil, username: nil, password: nil, security_token: nil) define_method('oauth_response') do + username = ERB.new(username).result(binding) if username + security_token = ERB.new(security_token).result(binding) if security_token + token_url = ERB.new(token_url).result(binding) if token_url + password = ERB.new(password).result(binding) if password payload = if password && username { grant_type: 'password', client_id: client_id, client_secret: client_secret, @@ -65,10 +69,10 @@ # Pass path to YAML file containing OAuth2 parameters # @param [String] path_to_filename Will have Soaspec.credentials_folder appended to it if set def oauth2_file(path_to_filename) full_path = Soaspec.credentials_folder ? File.join(Soaspec.credentials_folder, path_to_filename + '.yml') : path_to_filename + '.yml' - file_hash = eval(ERB.new(YAML.load_file(full_path).to_s).result(binding)) + file_hash = YAML.load_file(full_path) raise 'File at ' + full_path + ' is not a hash ' unless file_hash.is_a? Hash oauth_hash = file_hash.transform_keys_to_symbols oauth2 **oauth_hash end \ No newline at end of file