Skip to content

Commit 1cac6b0

Browse files
NoOne7135ivictbor
andauthored
docs: add documentation about Facebook OAuth (#148)
* docs: add documentation about Facebook OAuth * Update 11-oauth.md * docs: add installation instruction for Facebook OAuth adapter --------- Co-authored-by: Ivan Borshchov <[email protected]>
1 parent 8bca06d commit 1cac6b0

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

adminforth/documentation/docs/tutorial/05-Plugins/11-oauth.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ To install the plugin:
99
```bash
1010
npm install @adminforth/oauth --save
1111
npm install @adminforth/google-oauth-adapter --save # for Google OAuth
12+
npm install @adminforth/facebook-oauth-adapter --save # for Facebook OAuth
1213
```
1314

1415
## Configuration
@@ -17,8 +18,8 @@ npm install @adminforth/google-oauth-adapter --save # for Google OAuth
1718

1819
You need to get the client ID and client secret from your OAuth2 provider.
1920

20-
For Google:
21-
1. Go to the [Google Cloud Console](https://console.cloud.google.com)
21+
#### For Google:
22+
1. Go to the [Google Cloud Console](https://console.cloud.google.com) and log in.
2223
2. Create a new project or select an existing one
2324
3. Go to `APIs & Services``Credentials`
2425
4. Create credentials for OAuth 2.0 client IDs
@@ -32,6 +33,20 @@ GOOGLE_OAUTH_CLIENT_ID=your_google_client_id
3233
GOOGLE_OAUTH_CLIENT_SECRET=your_google_client_secret
3334
```
3435

36+
#### For Facebook:
37+
1. Go to the [Facebook Developers](https://developers.facebook.com/)
38+
2. Go to `My apps`
39+
3. Create a new project or select an existing one (choose Authenticate and request data from users with Facebook Login)
40+
4. Go to `Use Cases` - `Authenticate and request data from users with Facebook Login` -> `Customize` and add email permissions
41+
5. Go to `App Settings` -> `Basic`
42+
6. Get App ID and App secret
43+
7. Add the credentials to your `.env` file:
44+
45+
```bash
46+
FACEBOOK_OAUTH_CLIENT_ID=your_facebook_client_id
47+
FACEBOOK_OAUTH_CLIENT_SECRET=your_facebook_client_secret
48+
```
49+
3550
### 2. Plugin Configuration
3651

3752
Configure the plugin in your user resource file:

dev-demo/resources/users.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import OAuthPlugin from "../../plugins/adminforth-oauth";
1616
import AdminForthAdapterGoogleOauth2 from "../../adapters/adminforth-google-oauth-adapter";
1717
import AdminForthAdapterGithubOauth2 from "../../adapters/adminforth-github-oauth-adapter";
1818

19+
import AdminForthAdapterFacebookOauth2 from "../../adapters/adminforth-facebook-oauth-adapter";
20+
1921
export default {
2022
dataSource: "maindb",
2123
table: "users",
@@ -98,7 +100,11 @@ export default {
98100
clientID: process.env.GOOGLE_CLIENT_ID,
99101
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
100102
redirectUri: 'http://localhost:3000/oauth/callback',
101-
})
103+
}),
104+
new AdminForthAdapterFacebookOauth2({
105+
clientID: process.env.FACEBOOK_CLIENT_ID,
106+
clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
107+
}),
102108
],
103109
emailField: 'email',
104110
emailConfirmedField: 'email_confirmed'

0 commit comments

Comments
 (0)