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
#[], [], double_dispatch, #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.
8 9 10 |
# File 'lib/gh/token_check.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/gh/token_check.rb', line 8 def client_secret @client_secret end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/gh/token_check.rb', line 8 def token @token end |
Instance Method Details
#check_token ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gh/token_check.rb', line 18 def check_token return unless @check_token && client_id && client_secret && token @check_token = false auth_header = 'Basic %s' % Base64.strict_encode64("#{client_id}:#{client_secret}") http :post, path_for("/applications/#{client_id}/token"), body: "{\"access_token\": \"#{token}\"}", 'Authorization' => auth_header rescue GH::Error(response_status: 404) => e raise GH::TokenInvalid, e end |
#http ⇒ Object
30 31 32 33 |
# File 'lib/gh/token_check.rb', line 30 def http(*) check_token super end |
#setup(backend, options) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/gh/token_check.rb', line 10 def setup(backend, ) @client_secret = [:client_secret] @client_id = [:client_id] @token = [:token] @check_token = true super end |