fpm-auth: Discord OAuth Integration #663
Replies: 6 comments
-
I have created first pull request. It contains functionality for discord authorisation and saving access_token and discord user name in our cookies. Also discord logout feature. |
Beta Was this translation helpful? Give feedback.
-
I have pushed code in same PR having discord-server feature. |
Beta Was this translation helpful? Give feedback.
-
Another code pushed for discord-thread feature. |
Beta Was this translation helpful? Give feedback.
-
For discord-event functionality i will use below given apis and input params from ftd |
Beta Was this translation helpful? Give feedback.
-
For discord servers use below api |
Beta Was this translation helpful? Give feedback.
-
For discord i have implemented following functionalities. Discord Server Member Discord Thread Member Discord HasPermission Discord Scheduled Event |
Beta Was this translation helpful? Give feedback.
-
Status: Pending
Follow: #585
Author: Wasif
Code PR: #670
Doc PR: Pending
Discord Integartion
We are integrating with Discord in fpm, the user will be able to log in with Discord OAuth on fpm sites. Using Discord resources we are going to provide some user identities to use based on discord resources. For example, any logged-in user will be able to access the fpm pages if it is a part of the discord channel, discord server, etc...
In the below example, I have created a
user-group
with a single identitydiscord-family
and used it on route/family/
. If a user is a part of the discord channeldiscord-family
then only it will able to access the/family/
route.Create an OAuth Application
We have to create an OAuth Application on Discord to retrieve the
client ID
andclient secret
.Discord Create Application: https://discord.com/developers/applications
OAuth2 URLs
Base authorization URL: https://discord.com/oauth2/authorize
Token URL: https://discord.com/api/oauth2/token
Token Revocation URL: https://discord.com/api/oauth2/token/revoke
Discord OAuth2 Scopes
List of scopes the discord supports
guilds
: allows /users/@me/guilds to return basic information about all of a user's guildsguilds.members.read
: allows /users/@me/guilds/{guild.id}/member to return a user's member information in a guildidentify
: allows /users/@me without emailFor More...
State and Security
When a user begins the authorization flow on the client, a
state
is generated that is unique to that user's request. This valueis stored somewhere only accessible to the client and the user, i.e. protected by the same-origin policy When the user is redirected the
state
parameter is returned. The client validates the request by checking that thestate
matches the stored value.For More...
Authorization Code Grant
After clicking on the login button user will be redirected to the
Authorization URL
Authorization URL
Redirect URL
Access Token Exchange
After redirecting back to
abrark.com
withcode
andstate
,abrark's
service will exchange the token by passing thecode
from discord APIhttps://discord.com/api/v10
.Access Token Response
Discord Resources and FPM Identities
Discord Channel Member
discord-channel: <channel-id>
This identity will verify if the logged-in user is a member of the given channel.
API Details
Discord Server Member
discord-server: <server-id>
This identity will verify if the logged-in user is a member of the given server.
API Details
Discord Thread Member
discord-thread: <channel-id>
This identity will verify if the logged-in user is a member of the given thread.
API Details
Discord HasPermission
discord-permission: <todo>
API Details
Discord Scheduled Event
discord-event: <event-id>
This identity will verify if the logged-in user is a member of the given scheduled event.
API Details
Beta Was this translation helpful? Give feedback.
All reactions