Skip to content

Commit

Permalink
scope set from email to identify
Browse files Browse the repository at this point in the history
  • Loading branch information
adaoraul committed Aug 15, 2016
1 parent e12a525 commit 48db6b1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/omniauth/strategies/discord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
module OmniAuth
module Strategies
class Discord < OmniAuth::Strategies::OAuth2
DEFAULT_SCOPE = 'email'
DEFAULT_SCOPE = 'identify'

option :name, 'discord'

option :client_options, {
:site => 'https://discordapp.com/api',
:authorize_url => 'oauth2/authorize',
:token_url => 'oauth2/token'
}

option :authorize_options, [:scope]

uid { raw_info['id'] }

info do
Expand All @@ -23,8 +23,7 @@ class Discord < OmniAuth::Strategies::OAuth2
:username => raw_info['username'],
:discriminator => raw_info['discriminator'],
:avatar => raw_info['avatar'],
:verified => raw_info['verified'],
:email => raw_info['email']
:verified => raw_info['verified']
}
end

Expand All @@ -37,18 +36,18 @@ class Discord < OmniAuth::Strategies::OAuth2
def raw_info
@raw_info = access_token.get('users/@me').parsed
end

def callback_url
# Discord does not support query parameters
full_host + script_name + callback_path
end

def authorize_params
super.tap do |params|
options[:authorize_options].each do |option|
params[option] = request.params[option.to_s]
end

params[:redirect_uri] = options[:redirect_uri] unless options[:redirect_uri].nil?
params[:scope] ||= DEFAULT_SCOPE
end
Expand Down

0 comments on commit 48db6b1

Please sign in to comment.