Class: OmniAuth::Strategies::Bitbucket

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

Constant Summary collapse

EMAIL =
"email".freeze
ACCOUNT =
"account".freeze

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



15
16
17
18
19
20
21
22
# File 'lib/omniauth/strategies/bitbucket.rb', line 15

def authorize_params
  super.tap do |params|
    scope = params[:scope].to_s.split(/\s+/)
    scope << EMAIL unless scope.include?(EMAIL)
    scope << ACCOUNT unless scope.include?(ACCOUNT)
    params[:scope] = scope.join(" ")
  end
end

#callback_urlObject



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

def callback_url
  full_host + script_name + callback_path
end

#emailsObject



55
56
57
# File 'lib/omniauth/strategies/bitbucket.rb', line 55

def emails
  @emails ||= deep_symbolize(access_token.get("/api/2.0/user/emails").parsed).fetch(:values)
end

#primary_emailObject



59
60
61
# File 'lib/omniauth/strategies/bitbucket.rb', line 59

def primary_email
  (emails.find {|info| info["is_primary"] } || {})["email"]
end

#raw_infoObject



51
52
53
# File 'lib/omniauth/strategies/bitbucket.rb', line 51

def raw_info
  @raw_info ||= deep_symbolize(access_token.get("/api/2.0/user").parsed)
end