Sha256: be957a39f9d6036e72b244f5210bb5193a7adf8fad1a9363459b8f2e32ec6f54
Contents?: true
Size: 883 Bytes
Versions: 12
Compression:
Stored size: 883 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, path_for("/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
12 entries across 12 versions & 2 rubygems