Class: OmniAuth::Strategies::Ekuaishou

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

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omniauth/strategies/ekuaishou.rb', line 15

def authorize_params
  super.tap do |params|
    params[:app_id] = options.client_id if params[:app_id].to_s.strip.empty?

    if params[:scope]
      scope = params[:scope]
      scope = JSON.parse(params[:scope]) && params[:scope] rescue params[:scope].split(',') if scope.is_a?(String)
      params[:scope] = scope.is_a?(Array) ? scope.to_json : scope
    end

    %w[scope client_options].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]
        # to support omniauth-oauth2's auto csrf protection
        session['omniauth.state'] = params[:state] if v == 'state'
      end
    end
  end
end

#raw_infoObject



65
66
67
68
69
70
# File 'lib/omniauth/strategies/ekuaishou.rb', line 65

def raw_info
  @raw_info ||= begin
    resp = client.request(:get, "#{options.client_options[:site]}/rest/openapi/v1/advertiser/info", headers: headers, body: access_token.to_hash.slice('advertiser_id'))
    JSON.parse(resp.body)['data'] rescue {}
  end
end

#scopeObject



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

def scope
  access_token['scope']
end