File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
adminforth/documentation/docs/tutorial/05-Plugins Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,44 @@ plugins: [
299299]
300300```
301301
302+ ### Twitch Adapter
303+
304+ Install Adapter:
305+
306+ ```
307+ npm install @adminforth/twitch-oauth-adapter --save
308+ ```
309+
310+ 1 . Go to the [ Twitch dashboard] ( https://dev.twitch.tv/console/ )
311+ 2 . Create a new app or select an existing one
312+ 3 . In ` OAuth Redirect URLs ` add ` https://your-domain/oauth/callback ` (` http://localhost:3500/oauth/callback ` )
313+ 4 . Go to the app and copy ` Client ID ` , click to ` Generate a new client secret ` (in Twitch this button can be used only once for some time, becouse of this dont lose it) button and copy secret .
314+ 5 . Add the credentials to your ` .env ` file:
315+
316+ ``` bash
317+ TWITCH_OAUTH_CLIENT_ID=your_twitch_client_id
318+ TWITCH_OAUTH_CLIENT_SECRET=your_twitch_client_secret
319+ ```
320+
321+ Add the adapter to your plugin configuration:
322+
323+ ``` typescript title="./resources/adminuser.ts"
324+ import AdminForthAdapterTwitchOauth2 from ' @adminforth/twitch-oauth-adapter' ;
325+
326+ // ... existing resource configuration ...
327+ plugins : [
328+ new OAuthPlugin ({
329+ adapters: [
330+ ...
331+ new AdminForthAdapterTwitchOauth2 ({
332+ clientID: process .env .TWITCH_OAUTH_CLIENT_ID ,
333+ clientSecret: process .env .TWITCH_OAUTH_CLIENT_SECRET ,
334+ }),
335+ ],
336+ }),
337+ ]
338+ ```
339+
302340### Need custom provider?
303341
304342Just fork any existing adapter e.g. [ Google] ( https://github.com/devforth/adminforth-google-oauth-adapter ) and adjust it to your needs.
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import AdminForthAdapterGithubOauth2 from "../../adapters/adminforth-github-oau
1818import AdminForthAdapterFacebookOauth2 from "../../adapters/adminforth-facebook-oauth-adapter" ;
1919import AdminForthAdapterKeycloakOauth2 from "../../adapters/adminforth-keycloak-oauth-adapter" ;
2020import AdminForthAdapterMicrosoftOauth2 from "../../adapters/adminforth-microsoft-oauth-adapter" ;
21+ import AdminForthAdapterTwitchOauth2 from "../../adapters/adminforth-twitch-oauth-adapter" ;
2122import { randomUUID } from "crypto" ;
2223
2324declare global {
@@ -38,6 +39,8 @@ declare global {
3839 KEYCLOAK_REALM : string ;
3940 MICROSOFT_CLIENT_ID : string ;
4041 MICROSOFT_CLIENT_SECRET : string ;
42+ TWITCH_CLIENT_ID : string ;
43+ TWITCH_CLIENT_SECRET : string ;
4144
4245 }
4346 }
@@ -133,6 +136,10 @@ export default {
133136 clientSecret : process . env . MICROSOFT_CLIENT_SECRET ,
134137 useOpenID : true ,
135138 } ) ,
139+ new AdminForthAdapterTwitchOauth2 ( {
140+ clientID : process . env . TWITCH_CLIENT_ID ,
141+ clientSecret : process . env . TWITCH_CLIENT_SECRET ,
142+ } ) ,
136143 // new AdminForthAdapterKeycloakOauth2({
137144 // name: "Keycloak",
138145 // clientID: process.env.KEYCLOAK_CLIENT_ID,
You can’t perform that action at this time.
0 commit comments