Twitch
In this guide, you will learn how to enable Twitch authentication and onboard dApp users.
Prerequisites
- Make sure you can access Arcana Developer Dashboard: https://dashboard.arcana.network
- Install the
@arcana/auth
package. For details, see Arcana Auth Quick Start Guide.
Note that some steps are performed using Twitch Developer Dashboard, others using Arcana Dashboard. After that simply integrate your dApp with the Arcana Auth SDK to trigger Twitch login and onboard users.
To enable social authentication via Twitch in the Web3 applications, developers must perform these three steps before integrating with the Arcana Auth SDK.
Step 1: Use Arcana Dashboard
Go to the Arcana Dashboard: https://dashboard.arcana.network
Register your dApp by creating a new dApp entry and specifying a name using the 'Create New App' wizard.
Registering the Application
If you have already registered your dApp using Arcana Dashboard and obtained an Client ID, you may skip this step.
Use defaults for other settings or change them as per your use case. Refer to the how to configure dApp guide for details.
Go to the Configure->Social Auth
configuration section and copy the redirect URI value displayed there. This will be used in the next step to generate Twitch OAuth credentials.
Do not close the dashboard browser tab. Open another tab and set up Twitch OAuth. Then come back to the Dashboard tab and complete the dApp configuration settings.
Step 2: Use Twitch Developer Console
Go to the Twitch Developer Console and register your dApp as a new Twitch application.
Enter the application name.
Specify the Redirect URI copied from Arcana Dashboard in the previous step into the OAuth Redirect URL field of the Twitch Developer Console.
Copy the ClientID that is automatically generated by Twitch for the newly registered application in the Twitch Developer Console. It will be required in the next step while completing the Arcana dashboard dApp configuration.
Step 3: Update Arcana Dashboard
Revisit the Arcana Developer Dashboard portal. Click on your app entry and visit the application dashboard. Click Configure->Social Auth
in the LHS navigation bar. Refer to the "Twitch" field and paste the Client ID assigned by Twitch Developer Console, in the previous step, in the input text field.
Save the settings. Arcana Network assigns an Client ID to every registered and configured dApp. You need to save this Client ID and use it while integrating the dApp with the Auth SDK.
You are all set with the Twitch configuration. Integrate the Web3 application with the Arcana Auth SDK and call the user onboarding function when the user chooses to log in.
Tip
The Client ID is displayed on the top right of your dashboard.
You can revisit the Arcana Dashboard later to view and modify configuration settings.
Step 4: Integrate with Arcana Auth SDK and trigger Twitch login
Use the instructions here to integrate with Arcana Auth SDK
After integration, use the following code to trigger Twitch login to onboard users:
await auth.loginWithSocial('twitch')
Check if a user is logged in:
const connected = await auth.isLoggedIn()
Use other Auth SDK functions in your dApp. See Auth SDK Usage Guide for details.
Add code in the application to log out an authenticated user:
await auth.logout()
That is all!
Your dApp is all set for onboarding users via Twitch.
What's Next?
After enabling user sign-in via Twitch, you can allow authenticated users to access the Arcana wallet for signing blockchain transactions on any EVM-compatible network.
See also
- Arcana authentication concepts.
- How to integrate with Arcana Auth SDK
- Handling authentication errors