react-native-auth2.0-twitch
Version:
A lightweight React Native library for integrating Twitch OAuth 2.0 authentication using Android Custom Tabs. It allows you to securely authenticate users with Twitch by launching an external browser window (Custom Tabs) and handling the OAuth flow withou
44 lines (28 loc) • 1.1 kB
Markdown
auth 2.0 twitch
```sh
npm install react-native-auth2.0-twitch
```
You need to create an application and get the client_id
[](https://dev.twitch.tv/)
Mandatory for [iOS Universal Link](https://developer.apple.com/documentation/xcode/allowing-apps-and-websites-to-link-to-your-content/) and [Android App Link](https://developer.android.com/training/app-links?hl=en) for redirect
```js
import { useTwitchAuth } from 'react-native-auth2.0-twitch';
const { startAuth, error } = useTwitchAuth({
clientId: 'You client_id',
redirectUri: 'You redirect_uri',
onSuccess: (code) => {
console.log('Code auth:', code);
},
onError: (err) => {
console.error('Error auth:', err.message);
}
});
```
The result should be a code - which you can change to [access_token](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#authorization-code-grant-flow) and use it to get the user data.
[](https://dev.twitch.tv/docs/authentication/)
MIT