Authentification Discord OAuth
Échange un code OAuth Discord contre les informations et le jeton d'accès de l'utilisateur.
curl -X POST "https://duckia.fr/functions/discordAuth" \
-H "Content-Type: application/json" \
-d '{
"code": "example_string",
"redirect_uri": "example_string"
}'
import requests
import json
url = "https://duckia.fr/functions/discordAuth"
headers = {
"Content-Type": "application/json"
}
data = {
"code": "example_string",
"redirect_uri": "example_string"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://duckia.fr/functions/discordAuth", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"code": "example_string",
"redirect_uri": "example_string"
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"code": "example_string",
"redirect_uri": "example_string"
}`)
req, err := http.NewRequest("POST", "https://duckia.fr/functions/discordAuth", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://duckia.fr/functions/discordAuth')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request.body = '{
"code": "example_string",
"redirect_uri": "example_string"
}'
response = http.request(request)
puts response.body
{
"email": "user@example.com",
"discordUserId": "example_string",
"discordUsername": "John Doe",
"discordAvatar": "example_string",
"discordAccessToken": "example_string"
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred on the server",
"code": 500,
"requestId": "req_1234567890"
}
POST
/functions/discordAuth
POST
Base URLstring
Target server for requests. Edit to use your own host.
Content-Typestring
RequiredThe media type of the request body
Options: application/json
codestring
RequiredCode OAuth fourni par Discord.
redirect_uristring
RequiredURI de redirection utilisée lors de l'authentification.
Request Preview
Response
Response will appear here after sending the request
Body
application/json
codestring
RequiredCode OAuth fourni par Discord.
redirect_uristring
RequiredURI de redirection utilisée lors de l'authentification.
Responses
emailstring
Adresse e-mail associée au compte Discord.
discordUserIdstring
Identifiant Discord de l'utilisateur.
discordUsernamestring
Nom d'utilisateur Discord.
discordAvatarstring
Identifiant ou URL de l'avatar Discord.
discordAccessTokenstring
Jeton d'accès Discord.
Was this page helpful?