Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sishen/omniauth-bitbucket
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: gitclear/omniauth-bitbucket
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 12, 2019

  1. Copy the full SHA
    263fc44 View commit details

Commits on Jun 26, 2019

  1. Copy the full SHA
    fe54916 View commit details
Showing with 11 additions and 8 deletions.
  1. +10 −7 lib/omniauth/strategies/bitbucket.rb
  2. +1 −1 omniauth-bitbucket.gemspec
17 changes: 10 additions & 7 deletions lib/omniauth/strategies/bitbucket.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
require 'omniauth-oauth'
require 'omniauth-oauth2'

module OmniAuth
module Strategies
class Bitbucket < OmniAuth::Strategies::OAuth
class Bitbucket < OmniAuth::Strategies::OAuth2
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
option :client_options, {
:site => 'https://bitbucket.org',
:request_token_path => '/api/1.0/oauth/request_token',
:authorize_path => '/api/1.0/oauth/authenticate',
:access_token_path => '/api/1.0/oauth/access_token'
:authorize_url => 'https://bitbucket.org/site/oauth2/authorize',
:token_url => 'https://bitbucket.org/site/oauth2/access_token'
}

# These are called after authentication has succeeded. If
@@ -29,12 +28,16 @@ class Bitbucket < OmniAuth::Strategies::OAuth

def raw_info
@raw_info ||= begin
ri = MultiJson.decode(access_token.get('/api/1.0/user').body)['user']
email = MultiJson.decode(access_token.get('/api/1.0/emails').body).find { |email| email['primary'] }
ri = MultiJson.decode(access_token.get('/api/2.0/user').body)
email = MultiJson.decode(access_token.get('/api/2.0/user/emails').body)['values'].find { |email| email['is_primary'] }
ri.merge!('email' => email['email']) if email
ri
end
end

def callback_url
full_host + script_name + callback_path
end
end
end
end
2 changes: 1 addition & 1 deletion omniauth-bitbucket.gemspec
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|

# specify any dependencies here; for example:
s.add_dependency 'omniauth', '~> 1.1'
s.add_dependency 'omniauth-oauth', '~> 1.0'
s.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
s.add_dependency 'multi_json', '~> 1.7'

s.add_development_dependency 'rspec', '~> 2.7'