Skip to content

Commit b1be954

Browse files
authored
Merge pull request supabase#2189 from supabase/chore/guides
added discord authentication guide
2 parents 0a856d5 + 020bb9c commit b1be954

File tree

5 files changed

+107
-2
lines changed

5 files changed

+107
-2
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
id: auth-discord
3+
title: "Setting up Discord Auth"
4+
description: Add Discord OAuth to your Supabase project
5+
---
6+
7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
10+
11+
To enable Discord Auth for your project, you need to set up a Discord Application and add the Application OAuth credentials to your Supabase Dashboard.
12+
13+
## Overview
14+
15+
Setting up Discord logins for your application consists of 3 parts:
16+
17+
* Create and configure a Discord Application [Discord Developer Portal](https://discord.com/developers)
18+
* Add your Discord OAuth Consumer keys to your [Supabase Project](https://supabase.io)
19+
* Add the login code to your [Supabase JS Client App](https://github.com/supabase/supabase-js)
20+
21+
## Steps
22+
23+
### Access your Discord account
24+
25+
- Go to [discord.com](https://discord.com/).
26+
- Click on `Login` at the top right to log in.
27+
28+
![Discord Portal.](/img/guides/discord-portal.png)
29+
30+
- Once logged in, go to [discord.com/developers](https://discord.com/developers).
31+
32+
![Discord Portal.](/img/guides/discord-developer-portal.png)
33+
34+
35+
### Find your callback URL
36+
37+
In the next step you require a callback URL, which looks like this:
38+
39+
`https://<project-ref>.supabase.co/auth/v1/callback`
40+
41+
- Go to your [Supabase Project Dashboard](https://supabase.io).
42+
- Click on the `Settings` icon at the bottom of the left sidebar.
43+
- Click on `API` in the list.
44+
- Under Config / URL you'll find your API URL, you can click `Copy` to copy it to the clipboard.
45+
- Now just add `/auth/v1/callback` to the end of that to get your full `OAuth Redirect URI`.
46+
47+
<video width="99%" muted playsInline controls="true">
48+
<source src="/videos/api/api-url-and-key.mp4" type="video/mp4" muted playsInline />
49+
</video>
50+
51+
### Create a Discord Application
52+
53+
- Click on `New Application` at the top right.
54+
- Enter the name of your application and click `Create`.
55+
- Click on `OAuth2` under `Settings` in the left side panel.
56+
- Click `Add Redirect` under `Redirects`.
57+
- Type or paste your `callback URL` into the `Redirects` box.
58+
- Click `Save Changes` at the bottom.
59+
- Copy your `Client ID` and `Client Secret` under `Client information`.
60+
61+
### Add your Discord credentials into your Supabase Project
62+
63+
- Go to your [Supabase Project Dashboard](https://supabase.io)
64+
- In the left sidebar, click the `Authentication` icon (near the top)
65+
- Click `Settings` from the list to go to the `Authentication Settings` page
66+
- Enter the final (hosted) URL of your app under `Site URL` (this is important)
67+
- Under `External OAuth Providers` turn `Discord Enabled` to ON
68+
- Enter your `client_id` and `client_secret` saved in the previous step
69+
- Click `Save`
70+
71+
### Add login code to your client app
72+
73+
The JavaScript client code is documented here: [Supabase OAuth Client Code](https://supabase.io/docs/reference/javascript/auth-signin#sign-in-using-third-party-providers)
74+
75+
```js
76+
const { user, session, error } = await supabase.auth.signIn({
77+
provider: 'discord'
78+
})
79+
```
80+
81+
Add this function which you can call from a button, link, or UI element.
82+
83+
```js
84+
function signInWithDiscord() {
85+
const { user, session, error } = await supabase.auth.signIn({
86+
provider: 'discord'
87+
});
88+
}
89+
```
90+
91+
To log out:
92+
93+
```js
94+
function signout() {
95+
const { error } = await supabase.auth.signOut();
96+
}
97+
```
98+
99+
## Resources
100+
101+
* [Supabase Account - Free Tier OK](https://supabase.io)
102+
* [Supabase JS Client](https://github.com/supabase/supabase-js)
103+
* [Discord Account](https://discord.com)
104+
* [Discord Developer Portal](https://discord.com/developers)

web/docs/guides/database/full-text-search.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ select
427427
from
428428
books
429429
where
430-
to_tsvector(description) @@ to_tsquery('little <-> big');
430+
to_tsvector(description) @@ to_tsquery('big <-> dreams');
431431
```
432432

433433
</TabItem>
@@ -437,7 +437,7 @@ where
437437
const { data, error } = supabase
438438
.from('books')
439439
.select()
440-
.textSearch('description', `'little' <-> 'big'`)
440+
.textSearch('description', `'big' <-> 'dreams'`)
441441
```
442442

443443
</TabItem>

web/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ module.exports = {
142142
items: [
143143
'guides/auth/auth-apple',
144144
'guides/auth/auth-bitbucket',
145+
'guides/auth/auth-discord',
145146
'guides/auth/auth-facebook',
146147
'guides/auth/auth-github',
147148
'guides/auth/auth-gitlab',
730 KB
Loading
853 KB
Loading

0 commit comments

Comments
 (0)