Skip to content

Twitch oauth adapter #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions adminforth/documentation/docs/tutorial/05-Plugins/11-oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,44 @@ plugins: [
]
```

### Twitch Adapter

Install Adapter:

```
npm install @adminforth/twitch-oauth-adapter --save
```

1. Go to the [Twitch dashboard](https://dev.twitch.tv/console/)
2. Create a new app or select an existing one
3. In `OAuth Redirect URLs` add `https://your-domain/oauth/callback` (`http://localhost:3500/oauth/callback`)
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 .
5. Add the credentials to your `.env` file:

```bash
TWITCH_OAUTH_CLIENT_ID=your_twitch_client_id
TWITCH_OAUTH_CLIENT_SECRET=your_twitch_client_secret
```

Add the adapter to your plugin configuration:

```typescript title="./resources/adminuser.ts"
import AdminForthAdapterTwitchOauth2 from '@adminforth/twitch-oauth-adapter';

// ... existing resource configuration ...
plugins: [
new OAuthPlugin({
adapters: [
...
new AdminForthAdapterTwitchOauth2({
clientID: process.env.TWITCH_OAUTH_CLIENT_ID,
clientSecret: process.env.TWITCH_OAUTH_CLIENT_SECRET,
}),
],
}),
]
```

### Need custom provider?

Just fork any existing adapter e.g. [Google](https://github.com/devforth/adminforth-google-oauth-adapter) and adjust it to your needs.
Expand Down
7 changes: 7 additions & 0 deletions dev-demo/resources/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import AdminForthAdapterGithubOauth2 from "../../adapters/adminforth-github-oau
import AdminForthAdapterFacebookOauth2 from "../../adapters/adminforth-facebook-oauth-adapter";
import AdminForthAdapterKeycloakOauth2 from "../../adapters/adminforth-keycloak-oauth-adapter";
import AdminForthAdapterMicrosoftOauth2 from "../../adapters/adminforth-microsoft-oauth-adapter";
import AdminForthAdapterTwitchOauth2 from "../../adapters/adminforth-twitch-oauth-adapter";
import { randomUUID } from "crypto";

declare global {
Expand All @@ -38,6 +39,8 @@ declare global {
KEYCLOAK_REALM: string;
MICROSOFT_CLIENT_ID: string;
MICROSOFT_CLIENT_SECRET: string;
TWITCH_CLIENT_ID: string;
TWITCH_CLIENT_SECRET: string;

}
}
Expand Down Expand Up @@ -133,6 +136,10 @@ export default {
clientSecret: process.env.MICROSOFT_CLIENT_SECRET,
useOpenID: true,
}),
new AdminForthAdapterTwitchOauth2({
clientID: process.env.TWITCH_CLIENT_ID,
clientSecret: process.env.TWITCH_CLIENT_SECRET,
}),
// new AdminForthAdapterKeycloakOauth2({
// name: "Keycloak",
// clientID: process.env.KEYCLOAK_CLIENT_ID,
Expand Down