Skip to content
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

Update readme for example #9

Merged
merged 3 commits into from
May 19, 2023
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
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Remix Auth Twitch

Remix Auth plugin for Twitch
Demo app: https://remix-auth-twitch.pages.dev/

see also [example/README.md](example/README.md)

## Remix Auth plugin for Twitch

[Authentication | Twitch Developers](https://dev.twitch.tv/docs/authentication)

## Supported runtimes

| Runtime | Has Support |
| ---------- | ------------------------------------- |
| Node.js | ✅ |
| Cloudflare | Please try and tell me that it works. |
| Runtime | Has Support |
| ---------- | ----------- |
| Node.js | ✅ |
| Cloudflare | |

## How to use

Expand All @@ -19,6 +23,8 @@ Install remix-auth-twitch npm module along with remix-auth:

```
npm install remix-auth-twitch remix-auth

yarn add remix-auth-twitch remix-auth
```

### Prerequisites
Expand All @@ -35,13 +41,13 @@ npm install remix-auth-twitch remix-auth
See also [na2hiro/remix-auth-twitter: Remix Auth plugin for Twitter OAuth 1.0a](https://github.com/na2hiro/remix-auth-twitter)

```typescript
const twitchClientId = process.env.TWITCH_API_CLIENT;
const twitchClientSecret = process.env.TWITCH_API_SECRET;
const twitchClientId = process.env.TWITCH_API_CLIENT
const twitchClientSecret = process.env.TWITCH_API_SECRET
const twitchStrategy = new TwitchStrategy(
{
clientId: twitchClientId,
clientSecret: twitchClientSecret,
callbackURL: "http://localhost:3000/login/callback",
callbackURL: 'http://localhost:3000/login/callback',
includeEmail: true,
},
async ({ profile, token }) => {
Expand All @@ -51,10 +57,10 @@ const twitchStrategy = new TwitchStrategy(
name: profile.login,
email: profile.email,
accessToken: token.access_token,
};
}
}
);
authenticator.use(twitchStrategy, "twitch");
)
authenticator.use(twitchStrategy, 'twitch')
```

### [Validating Tokens | Twitch Developers](https://dev.twitch.tv/docs/authentication/validate-tokens)
Expand All @@ -65,9 +71,9 @@ First Validation is build-in TwitchStrategy, but Your application must validate

```ts
try {
await twitchStrategy.validate({ token: accessToken });
await twitchStrategy.validate({ token: accessToken })
} catch {
authenticator.logout(request, { redirectTo: "/login" });
authenticator.logout(request, { redirectTo: '/login' })
}
```

Expand Down
2 changes: 2 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Demo project for remix-auth-twitch

https://remix-auth-twitch.pages.dev/

## Environment variables

```sh
Expand Down
8 changes: 8 additions & 0 deletions example/app/routes/__layout._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export default function Page() {
ergofriend/remix-auth-twitch: Remix Auth Plugin for Twitch
</Link>
</li>
<li>
<Link
className='text-blue-200 underline'
to='https://www.npmjs.com/package/remix-auth-twitch'
>
remix-auth-twitch - npm
</Link>
</li>
</ul>

<p className='text-blue-300'>
Expand Down