A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://rubydoc.info/github/piotrmurach/github/master/Github/Request/OAuth2 below:

OAuth2 – Documentation for piotrmurach/github (master) – RubyDoc.info

Class: Github::Request::OAuth2
Inherits:
Faraday::Middleware show all
Includes:
Utils::Url
Defined in:
lib/github_api/request/oauth2.rb
Constant Summary collapse
ACCESS_TOKEN =
'access_token'.freeze
'Authorization'.freeze
Constants included from Utils::Url

Utils::Url::DEFAULT_QUERY_SEP, Utils::Url::KEY_VALUE_SEP

Instance Method Summary collapse Methods included from Utils::Url

#build_query, #escape, #escape_uri, #normalize, #parse_query, #parse_query_for_param, #unescape

Constructor Details #initialize(app, *args) ⇒ OAuth2

Returns a new instance of OAuth2.

29
30
31
32
33
# File 'lib/github_api/request/oauth2.rb', line 29

def initialize(app, *args)
  super app
  @app = app
  @token = args.shift
end
Instance Method Details #call(env) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/github_api/request/oauth2.rb', line 17

def call(env)
    params = { ACCESS_TOKEN => @token }.update query_params(env[:url])

  if token = params[ACCESS_TOKEN] and !token.empty?
    env[:url].query = build_query params
    env[:request_headers].merge!(AUTH_HEADER => "token #{token}")
  end

  @app.call env
end
#query_params(url) ⇒ Object
35
36
37
38
39
40
41
# File 'lib/github_api/request/oauth2.rb', line 35

def query_params(url)
  if url.query.nil? or url.query.empty?
    {}
  else
    parse_query url.query
  end
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4