Class: X::OAuthAuthenticator
- Inherits:
-
Authenticator
- Object
- Authenticator
- X::OAuthAuthenticator
- Defined in:
- lib/x/oauth_authenticator.rb
Overview
Authenticator for OAuth 1.0a authentication
Constant Summary collapse
- OAUTH_VERSION =
OAuth version
"1.0".freeze
- OAUTH_SIGNATURE_METHOD =
OAuth signature method
"HMAC-SHA1".freeze
- OAUTH_SIGNATURE_ALGORITHM =
OAuth signature algorithm
"sha1".freeze
Constants inherited from Authenticator
Authenticator::AUTHENTICATION_HEADER
Instance Attribute Summary collapse
-
#access_token ⇒ String
The access token.
-
#access_token_secret ⇒ String
The access token secret.
-
#api_key ⇒ String
The API key (consumer key).
-
#api_key_secret ⇒ String
The API key secret (consumer secret).
Instance Method Summary collapse
-
#header(request) ⇒ Hash{String => String}
Generate the OAuth authentication header for a request.
-
#initialize(api_key:, api_key_secret:, access_token:, access_token_secret:) ⇒ OAuthAuthenticator
constructor
Initialize a new OAuthAuthenticator.
Constructor Details
#initialize(api_key:, api_key_secret:, access_token:, access_token_secret:) ⇒ OAuthAuthenticator
Initialize a new OAuthAuthenticator
63 64 65 66 67 68 |
# File 'lib/x/oauth_authenticator.rb', line 63 def initialize(api_key:, api_key_secret:, access_token:, access_token_secret:) @api_key = api_key @api_key_secret = api_key_secret @access_token = access_token @access_token_secret = access_token_secret end |
Instance Attribute Details
#access_token ⇒ String
The access token
39 40 41 |
# File 'lib/x/oauth_authenticator.rb', line 39 def access_token @access_token end |
#access_token_secret ⇒ String
The access token secret
46 47 48 |
# File 'lib/x/oauth_authenticator.rb', line 46 def access_token_secret @access_token_secret end |
#api_key ⇒ String
The API key (consumer key)
25 26 27 |
# File 'lib/x/oauth_authenticator.rb', line 25 def api_key @api_key end |
#api_key_secret ⇒ String
The API key secret (consumer secret)
32 33 34 |
# File 'lib/x/oauth_authenticator.rb', line 32 def api_key_secret @api_key_secret end |
Instance Method Details
#header(request) ⇒ Hash{String => String}
Generate the OAuth authentication header for a request
77 78 79 80 |
# File 'lib/x/oauth_authenticator.rb', line 77 def header(request) method, url, query_params = parse_request(request) {AUTHENTICATION_HEADER => build_oauth_header(method, url, query_params)} end |