Sha256: ab47293dfca35a0761feee6e9f7148061f3c69b3e34bd36b7ff5d7d9da2e60e1
Contents?: true
Size: 873 Bytes
Versions: 3
Compression:
Stored size: 873 Bytes
Contents
require 'gh/error' require 'base64' module GH class TokenCheck < Wrapper attr_accessor :client_id, :client_secret, :token def setup(backend, options) @client_secret = options[:client_secret] @client_id = options[:client_id] @token = options[:token] @check_token = true super end def check_token return unless @check_token and client_id and client_secret and token @check_token = false auth_header = "Basic %s" % Base64.encode64("#{client_id}:#{client_secret}").gsub("\n", "") http :head, "/applications/#{client_id}/tokens/#{token}?client_id=#{client_id}&client_secret=#{client_secret}", "Authorization" => auth_header rescue GH::Error(:response_status => 404) => error raise GH::TokenInvalid, error end def http(*) check_token super end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gh-0.12.1 | lib/gh/token_check.rb |
gh-0.12.0 | lib/gh/token_check.rb |
gh-0.11.3 | lib/gh/token_check.rb |