All Projects → schwarz → ueberauth_discord

schwarz / ueberauth_discord

Licence: MIT license
Discord OAuth2 Strategy for Überauth.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to ueberauth discord

Pow assent
Multi-provider authentication for your Pow enabled app
Stars: ✭ 236 (+1866.67%)
Mutual labels:  oauth2, phoenix
ueberauth facebook
Facebook OAuth2 Strategy for Überauth.
Stars: ✭ 72 (+500%)
Mutual labels:  oauth2, ueberauth
psd2
API client for banks supporting PSD2 APIs with OAuth2 authentication.
Stars: ✭ 26 (+116.67%)
Mutual labels:  oauth2
mantle
📒 Easy and effective communication for any team or community.
Stars: ✭ 30 (+150%)
Mutual labels:  oauth2
wiresteward
Wireguard peer manager
Stars: ✭ 50 (+316.67%)
Mutual labels:  oauth2
king of tokyo
👑 King of Tokyo Multiplayer Board Game using Phoenix LiveView
Stars: ✭ 25 (+108.33%)
Mutual labels:  phoenix
GoogleSignIn-iOS
Enables iOS and macOS apps to sign in with Google.
Stars: ✭ 198 (+1550%)
Mutual labels:  oauth2
remix-auth
Simple Authentication for Remix
Stars: ✭ 929 (+7641.67%)
Mutual labels:  oauth2
rabbitmq-auth-backend-oauth2-spike
See rabbitmq/rabbitmq-auth-backend-oauth2 instead.
Stars: ✭ 17 (+41.67%)
Mutual labels:  oauth2
instagram-oauth-nodejs-server
Node.js server for Intagram-API OAuth purpose.
Stars: ✭ 12 (+0%)
Mutual labels:  oauth2
OAuthLogin.AspNetCore
第三方平台联合登陆(facebook、微信、微博、QQ、Kakao)
Stars: ✭ 43 (+258.33%)
Mutual labels:  oauth2
avatica
DEPRECATED - Moved to github.com/apache/calcite-avatica-go
Stars: ✭ 42 (+250%)
Mutual labels:  phoenix
course planner
An application to manage educational courses
Stars: ✭ 36 (+200%)
Mutual labels:  phoenix
OAuthLogin
第三方平台联合登陆(facebook、微信、微博、QQ、Kakao)
Stars: ✭ 57 (+375%)
Mutual labels:  oauth2
Simpler
Simpler是一款轻量级的第三方微博应用,具有微博的基础功能,兼有外观优雅,运行流畅,内存占用低,省电省流量等特点。
Stars: ✭ 27 (+125%)
Mutual labels:  oauth2
ga-fetcher
Fetch Google Analytics data with Google APIs in Node.js 🚠
Stars: ✭ 14 (+16.67%)
Mutual labels:  oauth2
sample-oauth2-client
Sample OAuth2 client using the GitHub API
Stars: ✭ 69 (+475%)
Mutual labels:  oauth2
cordova-spotify-oauth
🔐 Easy Spotify authentication for Cordova / PhoneGap apps
Stars: ✭ 15 (+25%)
Mutual labels:  oauth2
OAuth2-Go
OAuth2 sample app using Go
Stars: ✭ 19 (+58.33%)
Mutual labels:  oauth2
Twitch
[READ ONLY] Subtree split of the SocialiteProviders/Twitch Provider (see SocialiteProviders/Providers)
Stars: ✭ 20 (+66.67%)
Mutual labels:  oauth2

Überauth Discord

Hex pm Hexdocs.pm

Discord OAuth2 strategy for Überauth.

For additional documentation on Discord's OAuth implementation see discord-oauth2-example.

Installation

  1. Setup your application at Discord Developers.

  2. Add :ueberauth_discord to your list of dependencies in mix.exs:

    def deps do
      [{:ueberauth_discord, "~> 0.6"}]
    end
  3. Add Discord to your Überauth configuration:

    config :ueberauth, Ueberauth,
      providers: [
        discord: {Ueberauth.Strategy.Discord, []}
      ]
  4. Update your provider configuration:

    config :ueberauth, Ueberauth.Strategy.Discord.OAuth,
      client_id: System.get_env("DISCORD_CLIENT_ID"),
      client_secret: System.get_env("DISCORD_CLIENT_SECRET")
  5. Include the Überauth plug in your controller:

    defmodule MyApp.AuthController do
      use MyApp.Web, :controller
      plug Ueberauth
      ...
    end
  6. Create the request and callback routes if you haven't already:

    scope "/auth", MyApp do
      pipe_through :browser
    
      get "/:provider", AuthController, :request
      get "/:provider/callback", AuthController, :callback
    end

    And make sure to set the correct redirect URI(s) in your Discord application to wire up the callback.

  7. Your controller needs to implement callbacks to deal with Ueberauth.Auth and Ueberauth.Failure responses.

For an example implementation see the Überauth Example application.

Calling

Auth

Depending on the configured url you can initialize the request through:

/auth/discord

Or with options:

/auth/discord?scope=identify%20email&prompt=none&permissions=452987952

By default the requested scope is "identify". Scope can be configured either explicitly as a scope query value on the request path or in your configuration:

config :ueberauth, Ueberauth,
  providers: [
    discord: {Ueberauth.Strategy.Discord, [default_scope: "identify email connections guilds"]}
  ]

You can also specify the prompt and permissions params to pass to Discord:

config :ueberauth, Ueberauth,
  providers: [
    discord: {Ueberauth.Strategy.Discord, [
      default_scope: "identify email connections guilds",
      prompt: "none",
      permissions: 452987952
    ]}
  ]

Bot

This library can also be used to add bots to guilds.

When adding bots, the scope should be set to bot and permissions should be set so your bot can perform actions in the host guild.

You can use the following parameters in addition to the ones specified for the user auth flow:

  • guild_id - pre-select the guild to which the bot will be added
  • disable_guild_select - disable the dropdown to select a guild (can improve UX by limiting choices)

Usage would look like the following:

your_link_building_method(
  :request,
  "discord",
  scope: "bot",
  guild_id: guild_id,
  disable_guild_select: true,
  permissions: my_default_bot_permissions()
)

This should produce a link with the following format:

https://discord.com/oauth2/authorize?client_id=<YOUR_CLIENT_ID>&disable_guild_select=true&guild_id=<SOME_GUILD_ID>&permissions=<DEFAULT_BOT_PERMISSIONS>&redirect_uri=<YOUR_DISCORD_CALLBACK_URI>&response_type=code&scope=bot&state=ebla7tFnIyX_FdmY5wjW8u7NJkc

License

Please see LICENSE for licensing details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].