OathWall

Twitch Login in Unity (OAuth, no backend)

The Oathwall Team2 min read

If your game has a Twitch community — a stream-integrated title, a streamer tool, a game people play on camera — "Sign in with Twitch" is a login your players already recognize. This guide sets it up with OAuth, no backend, and covers the one scope that decides whether you get an email or not.

When Twitch login fits

Twitch is the identity of the live-streaming crowd. It fits stream-integrated games (where viewers interact with the broadcast), streamer-facing tools, and games whose community already lives on Twitch. If your players are streaming or watching anyway, signing in with Twitch is one tap and feels native. For a broad audience beyond that community, offer it beside a mainstream provider like Google or Apple rather than on its own.

Step 1: Register a Twitch application

  1. Go to the Twitch Developer Console and click Register Your Application.
  2. Set the OAuth Redirect URL to exactly:
https://sso.oathwall.com/auth/callback
  1. Pick a category, create the app, and copy the Client ID and generate a Client Secret.

Step 2: Paste your credentials into Oathwall

In the Oathwall dashboard, add Twitch as a provider and paste the Client ID and Client Secret. The secret stays server-side; Oathwall runs the token exchange and reads the profile through Twitch's Helix API for you. Oathwall requests the user:read:email scope so the account email comes back — without that scope Twitch returns the profile but no address.

Step 3: Wire it up in Unity

Same base class, same single call as every other provider:

using PixitGames.SSOLoginKit;

public class LoginManager : SsoClientBase
{
    // user:read:email scope. Client secret stays on
    // Oathwall's servers, not in your build.
    public void OnTwitchButton() => StartLogin("twitch");

    protected override void OnLoginSuccess(LoginResult user)
    {
        // user.name is the Twitch display name.
        LinkPlayer(user.id, user.name);
    }
}

StartLogin("twitch") opens Twitch's authorization page in the system browser. Oathwall exchanges the code and reads the account through Helix — user.id is Twitch's numeric user id, user.name is the display name (with the login handle as a fallback), and user.email is the account email when the user:read:email scope is granted.

The gotchas worth knowing

Email hinges on one scope. Twitch only returns an email if the app requested user:read:email. Oathwall asks for it, so you get the primary account email — but a user can still decline, so write for the case where user.email is empty and rely on the stable user.id.

Display names change; ids don't. Twitch lets users change their display name, and the display name can differ in casing from the login handle. Use user.name as a label in your UI, but key player records on the numeric user.id so a name change never orphans a save. This is the same rule Discord pushes you toward with its username-versus-global-name split.

It's a community login, not a universal one. Twitch reaches the streaming audience well and everyone else poorly. Offering it next to a mainstream provider is the pattern — Twitch for the community that has an account, Google or Apple for the rest.

The Unity authentication guide shows several providers sharing one login class, so adding Twitch is one more StartLogin call rather than a separate integration.

Frequently asked questions

Do I need a backend to add Twitch login?
No. Oathwall runs the OAuth token exchange on its servers using your Twitch client secret, which never ships in your build. Your Unity game only carries the public appKey and calls StartLogin("twitch").
What scope do I need to get the player's email from Twitch?
user:read:email. Without it, Twitch returns the profile — display name, login, and avatar — but no email. Oathwall requests it so the primary account email comes back when the user grants access.
What does Twitch give me about the player?
A stable numeric user id, a display name, the login handle, the account email (with user:read:email), and a profile image URL. Key your player records on the id, not the display name — Twitch lets people change their display name.
Is Twitch login a good fit for my game?
It's a strong fit for streamer-facing tools, games with a Twitch community, stream-integrated games, and anything targeting the live-streaming audience. For a general consumer game, pair it with Google or Apple for wider reach.