Module: BWAPI::Authentication
- Included in:
- Client
- Defined in:
- lib/bwapi/authentication.rb
Overview
Authentication module helper methods
Instance Method Summary collapse
-
#api_client? ⇒ Boolean
Check if user is a brandwatch-api-client type.
-
#application_client? ⇒ Boolean
Check if user is a brandwatch-application-client type.
-
#authenticated? ⇒ Boolean
Check if user is authenicated.
-
#netrc_credentials(netrc = false) ⇒ Object
Set username and password via netrc.
Instance Method Details
#api_client? ⇒ Boolean
Check if user is a brandwatch-api-client type
24 25 26 |
# File 'lib/bwapi/authentication.rb', line 24 def api_client? client_id == 'brandwatch-api-client' ? true : false end |
#application_client? ⇒ Boolean
Check if user is a brandwatch-application-client type
17 18 19 |
# File 'lib/bwapi/authentication.rb', line 17 def application_client? client_id == 'brandwatch-application-client' ? true : false end |
#authenticated? ⇒ Boolean
Check if user is authenicated
10 11 12 |
# File 'lib/bwapi/authentication.rb', line 10 def authenticated? !!access_token end |
#netrc_credentials(netrc = false) ⇒ Object
Set username and password via netrc
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bwapi/authentication.rb', line 31 def netrc_credentials netrc=false return unless netrc require 'netrc' file = Netrc.read netrc_file # Get credentials using host netrc_host = URI.parse(api_endpoint).host creds = file[netrc_host] raise 'You are missing your .netrc file or the host provided has no credentials!'.red.underline if creds.nil? self.username = creds.shift self.password = creds.shift rescue LoadError raise "Please install netrc gem for .netrc support".red.underline end |