Class: MessageMediaLookups::BasicAuth
- Inherits:
-
Object
- Object
- MessageMediaLookups::BasicAuth
- Defined in:
- lib/message_media_lookups/http/auth/basic_auth.rb
Overview
Utility class for basic authorization.
Class Method Summary collapse
-
.apply(http_request) ⇒ Object
Add basic authentication to the request.
Class Method Details
.apply(http_request) ⇒ Object
Add basic authentication to the request. be added.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/message_media_lookups/http/auth/basic_auth.rb', line 10 def self.apply(http_request) username = Configuration.basic_auth_user_name password = Configuration.basic_auth_password if(username.length != 20 || password.length != 30) puts("~~~~~ It appears as though your REST API Keys are invalid. Please check and make sure they are correct. (Invalid Length) ~~~~~") end value = Base64.strict_encode64("#{username}:#{password}") header_value = "Basic #{value}" http_request.headers['Authorization'] = header_value end |