discordoauth2
Service icon

DiscordOAuth2

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 13 December 2022
 by 
0.0
 (0 ratings)
discordoauth2

DiscordOAuth2

Documentation
1.0.0


1. Get your Client Id and Client Secret

The first step in implementing OAuth2 is registering a developer application and retrieving your client ID and client secret.

After you create your application with Discord, make sure that you save your client_id and client_secret in the site properties.


2. Retrieve the Authorization Code Grant



The authorization code grant is what most developers will recognize as "standard OAuth2" and involves retrieving an access code and exchanging it for a user's access token.

It allows the authorization server to act as an intermediary between the client and the resource owner, so the resource owner's credentials are never shared directly with the client.

The URL will look something like this:


Here the client_id is your application's client_id which we got in the previous step. The scope is what permissions you request from the user for more scopes visit here. For clients and guilds details, we are using the "identify%20guilds".
The redirect_uri, is where you will be redirected after granting authorization, you have to add the redirect url in your application page and encode the URL, here we are using "EncodeUrl("https://gdclopes.outsystemscloud.com/DiscordDemo/Landing")"

3. Access Token Exchange

The authorization code is now exchanged for the user's access token by making a POST request to the token URL with the following parameters:

client_id - your application's client id
client_secret - your application's client secret
grant_type - must be set to "authorization_code"
code - the code from the querystring
redirect_uri - the redirect_uri associated with this authorization, usually from your authorization URL

You can also pass your client_id and client_secret as basic authentication with client_id as the username and client_secret as the password.