class OmniAuth::Strategies::WIP

Public Instance Methods

callback_url() click to toggle source

github.com/intridea/omniauth-oauth2/issues/81

# File lib/omniauth/strategies/wip.rb, line 35
def callback_url
  full_host + script_name + callback_path
end
raw_info() click to toggle source
# File lib/omniauth/strategies/wip.rb, line 30
def raw_info
  @raw_info ||= wip_client
end

Private Instance Methods

make_request(query) click to toggle source
# File lib/omniauth/strategies/wip.rb, line 60
def make_request(query)
  response = Faraday.post("https://wip.chat/graphql") do |request|
    request.headers["Authorization"] = "bearer #{credentials["token"]}"
    request.headers["Content-Type"] = "application/json"
    request.body = { query: query }.to_json
  end

  json = JSON.parse(response.body)
  raise json["errors"].first["message"] if json.key? "errors"

  json["data"]
end
viewer_query() click to toggle source
# File lib/omniauth/strategies/wip.rb, line 46
def viewer_query
  %(
    {
      viewer {
        id
        username
        url
        first_name
        last_name
      }
    }
  )
end
wip_client() click to toggle source
# File lib/omniauth/strategies/wip.rb, line 41
def wip_client
  data = make_request viewer_query
  data["viewer"]
end