react-native-auth2.0-twitch
v1.2.3
Published
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
Maintainers
Readme
react-native-auth2.0-twitch
auth 2.0 twitch
Installation
npm install react-native-auth2.0-twitchUsage
You need to create an application and get the client_id
Mandatory for iOS Universal Link and Android App Link for redirect
import { useTwitchAuth } from 'react-native-auth2.0-twitch';
const { startAuth, error } = useTwitchAuth({
clientId: 'You client_id',
redirectUri: 'You redirect_uri',
// Optional: force the Twitch consent/login screen even if the user already authorized your app
// Maps to the Twitch "force_verify" parameter. Default is false.
forceVerify: false,
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 and use it to get the user data.
force_verify (optional)
- What: When enabled, Twitch will always show the login/consent screen, even if the user already authorized your app before (equivalent to Twitch’s force_verify parameter).
- Why: Useful to ensure a fresh login, prompt the user to re-consent, or let them switch accounts explicitly.
- How: Set forceVerify: true in the hook options:
useTwitchAuth({
// ...existing options...
forceVerify: true,
});Twitch OAuth Documentation
License
MIT
