Class: OmniAuth::Strategies::Pinterest

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

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject

You can pass display, scope, or auth_type params to the auth request, if you need to set them dynamically. You can also set these options in the OmniAuth config :authorize_params option.

For example: /auth/pinterest?display=popup



37
38
39
40
41
42
43
44
45
# File 'lib/omniauth/strategies/pinterest.rb', line 37

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

    params[:scope] ||= DEFAULT_SCOPE
  end
end

#basic_auth_headerObject



56
57
58
59
60
61
62
# File 'lib/omniauth/strategies/pinterest.rb', line 56

def basic_auth_header
  auth =
    Base64.strict_encode64(
      "#{options[:client_id]}:#{options[:client_secret]}",
    )
  "Basic #{auth}"
end

#build_access_tokenObject



47
48
49
50
51
52
53
54
# File 'lib/omniauth/strategies/pinterest.rb', line 47

def build_access_token
  options.token_params.merge!(
    headers: {
      'Authorization' => basic_auth_header,
    },
  )
  super
end

#callback_urlObject



64
65
66
# File 'lib/omniauth/strategies/pinterest.rb', line 64

def callback_url
  full_host + script_name + callback_path
end

#raw_infoObject



24
25
26
27
# File 'lib/omniauth/strategies/pinterest.rb', line 24

def raw_info
  access_token.options[:parse] = :json
  @raw_info ||= access_token.get('/v5/user_account').parsed
end

#request_phaseObject



14
15
16
17
18
# File 'lib/omniauth/strategies/pinterest.rb', line 14

def request_phase
  options[:scope] ||= 'user_accounts:read'
  options[:response_type] ||= 'code'
  super
end

#ssl?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/omniauth/strategies/pinterest.rb', line 29

def ssl?
  request.scheme == 'https'
end