Discord OAuth2 Strategy for OmniAuth.
Read the Discord API documentation for more details: https://discordapp.com/developers/docs/topics/oauth2
Add to your Gemfile:
gem 'omniauth-discord'Then bundle install.
OmniAuth::Strategies::Discord is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_SECRET']
endBy default, Discord does not return a user's email address. Their API uses
scopes to provide
access to certain resources of a user's account. For example, to get a user's
email set the scope to email.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_SECRET'], scope: 'email'
endYou can pass multiple scopes in the same string. For example to get a user's
Discord account info set the scope to email identify
Rails.application.config.middleware.use OmniAuth::Builder do
provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_SECRET'], scope: 'email identify'
endBug reports and pull requests are welcome on GitHub at https://github.com/adaoraul/omniauth-discord.
The gem is available as open source under the terms of the MIT License.