How to Set Up OAuth Social Login
This guide walks you through configuring social login so customers can sign in to client PCs using their Google, Facebook, Apple, X, or Discord accounts. HandyCafe uses the Device Authorization Grant flow (RFC 8628), which is designed for devices without a full browser. Customers scan a QR code with their phone to authenticate.
What You Will Need
- Admin access to the HandyCafe Server.
- A Google Cloud Console account (for Google OAuth) or equivalent developer portal access for other providers.
- The HandyCafe Server running and accessible on your network.
- At least one connected client PC to test the login flow.
How OAuth Device Flow Works in HandyCafe
Before diving into setup, here is a summary of the flow:
- A customer at an idle client PC clicks the social login button (e.g., "Sign in with Google").
- The client sends an OAuth start request to the server.
- The server contacts the provider's device authorization endpoint and receives a device code, a user code, and a verification URL.
- The client displays a QR code and the user code on the idle screen.
- The customer scans the QR code with their phone and authenticates with the provider.
- The server polls the provider until authentication completes.
- The server creates an OAuth Login Request that appears on the Requests page.
- An admin or cashier approves the request.
- A new member account is created (or an existing account is linked) and the customer is logged in.
How to Set Up Google OAuth
Google is the most commonly used provider. This section covers every step from creating the Google Cloud project to testing the first login.
Part A: Create Google Cloud Credentials
- Open the Google Cloud Console at https://console.cloud.google.com in your browser.
- Create a new project or select an existing one. Name it something recognizable like "HandyCafe OAuth."
- Navigate to APIs & Services > OAuth consent screen.
- Select External as the user type (unless you have a Google Workspace organization and want internal only).
- Fill in the required fields: App name ("Your Cafe Name"), User support email, and Developer contact email.
- Click Save and Continue through the Scopes and Test Users sections. You do not need to add special scopes. The default email and profile scopes are sufficient.
- Navigate to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- For Application type, select TVs and Limited Input devices. This is critical. HandyCafe uses the device authorization grant flow, which requires this specific client type.
- Enter a name for the client (e.g., "HandyCafe Device Flow").
- Click Create.
- Copy the Client ID and Client Secret from the confirmation dialog. Store them securely. You will need both values in the next section.
Part B: Configure HandyCafe Server
- Open the HandyCafe Server application.
- Navigate to Settings using the gear icon in the left sidebar.
- Select the OAuth tab.
- Enable the OAuth toggle at the top of the page. This globally enables social login across all client PCs.
- Locate the Google provider row in the providers list.
- Enable the Google toggle to activate this provider.
- Paste your Client ID from step 12 into the Client ID field.
- Paste your Client Secret from step 12 into the Client Secret field.
- Click Save to apply the configuration.
Expected result: The OAuth tab shows Google as enabled with your credentials filled in. The settings are pushed to all connected clients.
Part C: Test the Login Flow
- Go to a connected client PC. The idle screen should now show a social login section with a Google login button.
- Click the Google login button on the client idle screen.
- The client displays a QR code and a user code (a short alphanumeric string).
- Scan the QR code with your phone. It opens Google's device verification page.
- Sign in with a Google account and enter the user code when prompted.
- Authorize the application.
Expected result: On the server, a notification sound plays and a new entry appears on the Requests page. The request shows the Google account name, email address, and the client PC that initiated the login.
How to Approve a Login Request
Every OAuth login generates a request that must be approved by an admin or cashier before the customer gains access.
- When a login request arrives, a notification sound plays on the server and a badge appears on the Requests page icon in the sidebar.
- Navigate to the Requests page.
- The pending request shows:
- Provider name (e.g., Google).
- Display name from the provider (e.g., "John Smith").
- Email address (e.g., "john@example.com").
- The client PC that initiated the request (hostname or display name).
- Timestamp.
- Review the request details. Verify that the person at the client PC matches the account information.
- Click Approve to accept the request.
Expected result: If no existing member account is linked to this OAuth identity, a new member account is created automatically. The display name and email from the provider are used. The customer is logged in and the client PC transitions from the idle screen to the Online Page. If a member account was previously linked to this OAuth identity, the existing member is logged in directly.
Tip: If the login request is suspicious (e.g., the PC is unattended or the request looks automated), click Reject instead. The customer will see an "Access denied" message and can try again.
How to Set Up Facebook OAuth
- Open the Facebook Developer Portal at https://developers.facebook.com .
- Create a new app. Select the Consumer app type.
- Navigate to the app's Settings > Basic page. Note the App ID and App Secret.
- Navigate to Add Product and add Facebook Login for Devices.
- In the Facebook Login for Devices settings, add your redirect URIs if required by the portal.
- Open the HandyCafe Server and navigate to Settings > OAuth.
- Locate the Facebook provider row.
- Enable the Facebook toggle.
- Paste the App ID into the Client ID field.
- Paste the App Secret into the Client Secret field.
- Click Save.
Expected result: Facebook appears as an enabled provider. Client idle screens show a Facebook login button alongside any other enabled providers.
How to Set Up Discord OAuth
- Open the Discord Developer Portal at https://discord.com/developers/applications .
- Create a new application. Name it after your cafe.
- Navigate to the OAuth2 section in the left sidebar.
- Copy the Client ID and generate a Client Secret. Store the secret securely as Discord only shows it once.
- Open the HandyCafe Server and navigate to Settings > OAuth.
- Locate the Discord provider row (it is disabled by default).
- Enable the Discord toggle.
- Paste the Client ID into the Client ID field.
- Paste the Client Secret into the Client Secret field.
- Click Save.
Expected result: Discord is now available as a login option on client idle screens.
How to Allow Login Without Credit
By default, HandyCafe allows OAuth-authenticated customers to log in even if they have no wallet balance or time credit. You can change this behavior.
- Navigate to Settings > OAuth.
- Locate the Allow Login Without Credit toggle.
- If enabled (default), customers who authenticate via OAuth can log in regardless of their balance. A cashier can start a postpaid session for them.
- If disabled, customers must have either a wallet balance or time credit to log in. Customers with zero balance will see a message telling them to visit the cashier to top up.
- Click Save after changing the toggle.
Expected result: The behavior takes effect immediately for new login requests. Existing sessions are not affected.
How to Link an OAuth Identity to an Existing Member
If a customer already has a member account (created manually by a cashier) and then logs in via OAuth for the first time, the approval process can link the OAuth identity to their existing account.
- When the OAuth login request arrives on the Requests page, check if the email matches an existing member.
- If the system detects a match, the approval dialog will offer to link the OAuth identity to the existing member instead of creating a new account.
- Approve the request with the link option selected.
Expected result: The existing member account gains an OAuth link. Future logins from this provider will bypass the approval step and log the member in directly (after the first approval).
Common Mistakes to Avoid
- Using the wrong OAuth client type in Google Cloud Console. You must select "TVs and Limited Input devices" when creating the OAuth client ID. If you select "Web application" or "Desktop app," the device authorization flow will not work and the client will fail to get a device code.
- Forgetting to enable the global OAuth toggle. Enabling individual providers is not enough. The master OAuth toggle at the top of the OAuth settings page must also be on.
- Not approving login requests. OAuth logins require explicit approval from the server. If no one monitors the Requests page, customers will wait indefinitely at the idle screen. Consider assigning a cashier to monitor requests during busy hours.
- Letting device codes expire. Device codes have a limited lifetime (typically 5-10 minutes). If the customer takes too long to scan the QR code and authenticate, the code expires and they must start over. Advise customers to scan promptly.
- Pasting credentials with extra whitespace. When copying Client ID or Client Secret from the provider console, ensure no leading or trailing spaces are included. Extra whitespace will cause authentication failures.
- Forgetting to publish the Google OAuth app. Google apps in "Testing" mode only allow a limited number of test users. To allow any customer to log in, you must publish the app through the OAuth consent screen page and complete any required verification steps.
- Mixing up Client ID and Client Secret. These are two different values. The Client ID is public-facing. The Client Secret must be kept confidential. Swapping them will cause authentication failures.
- Not configuring the cafe name. The cafe name from your HandyCafe settings is displayed on the client idle screen during the OAuth flow. A blank or default name looks unprofessional. Set your cafe name in Settings > General before enabling OAuth.