Class: OmniAuth::Strategies::Linear

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/linear.rb

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



23
24
25
26
27
28
29
30
31
# File 'lib/omniauth/strategies/linear.rb', line 23

def authorize_params
  super.tap do |params|
    %w[client_options].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]
      end
    end
  end
end

#callback_urlObject



72
73
74
# File 'lib/omniauth/strategies/linear.rb', line 72

def callback_url
  full_host + script_name + callback_path
end

#meObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/omniauth/strategies/linear.rb', line 43

def me
  @me ||= begin
    http = GraphQL::Client::HTTP.new(options.client_options.site) do |obj|
      def headers(context)
        {"Authorization" => "Bearer #{context[:token]}"}
      end
    end
    schema = GraphQL::Client.load_schema(http)
    client = GraphQL::Client.new(schema: schema, execute: http)
    client.allow_dynamic_queries = true

    gql = client.parse <<~GRAPHQL
      query {
        organization {
          id
          name
        }
        viewer {
          id
          name
          email
        }
      }
    GRAPHQL
    response = client.query(gql, context: {token: access_token.token})
    response.data.to_h
  end
end

#raw_infoObject



39
40
41
# File 'lib/omniauth/strategies/linear.rb', line 39

def raw_info
  @raw_info ||= {}
end

#request_phaseObject



19
20
21
# File 'lib/omniauth/strategies/linear.rb', line 19

def request_phase
  super
end