Class: GH::TokenCheck
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#token ⇒ Object
Returns the value of attribute token.
Attributes inherited from Wrapper
Instance Method Summary collapse
Methods inherited from Wrapper
[], #[], #frontend, #frontend=, #generate_response, #initialize, #inspect, #load, #prefixed, #reset, wraps
Constructor Details
This class inherits a constructor from GH::Wrapper
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/gh/token_check.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/gh/token_check.rb', line 6 def client_secret @client_secret end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/gh/token_check.rb', line 6 def token @token end |
Instance Method Details
#check_token ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/gh/token_check.rb', line 16 def check_token return unless @check_token and client_id and client_secret and token auth_header = "Basic %s" % Base64.encode64("#{client_id}:#{client_secret}").gsub("\n", "") http :head, "/applications/#{client_id}/tokens/#{token}", "Authorization" => auth_header @check_token = false rescue GH::Error => error raise GH::TokenInvalid, error end |
#fetch_resource ⇒ Object
25 26 27 28 |
# File 'lib/gh/token_check.rb', line 25 def fetch_resource(*) check_token super end |
#setup(backend, options) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/gh/token_check.rb', line 8 def setup(backend, ) @client_secret = [:client_secret] @client_id = [:client_id] @token = [:token] @check_token = true super end |