- Accordion
- Action Sheet
- Alert
- Alert Dialog
- Audio Player
- Audio Recorder
- Audio Waveform
- Avatar
- AvoidKeyboard
- Badge
- BottomSheet
- Button
- Camera
- Camera Preview
- Card
- Carousel
- Checkbox
- Collapsible
- Color Picker
- Combobox
- Date Picker
- File Picker
- Gallery
- Hello Wave
- Icon
- Image
- Input
- Input OTP
- Link
- MediaPicker
- Mode Toggle
- Onboarding
- ParallaxScrollView
- Picker
- Popover
- Progress
- Radio
- ScrollView
- SearchBar
- Separator
- Share
- Sheet
- Skeleton
- Spinner
- Switch
- Table
- Tabs
- Text
- Toast
- Toggle
- Video
- View
Overview
This guide will walk you through setting up Sign in with Apple authentication for your Convex application. By the end of this setup, your users will be able to sign in using their Apple accounts.
Important Note: Unlike other providers, Apple doesn't allow you to test your Sign in with Apple integration using an app running on localhost. You'll need to fully deploy your application to a public site with a valid SSL certificate.
Prerequisites
Before starting, ensure you have:
- An Apple Developer account (create one at Apple Developer)
- A Convex project set up and deployed to production
- Access to your Convex deployment's HTTP Actions URL
- A deployed application with a valid SSL certificate (HTTPS required)
Step 1: Create an App ID
- Navigate to the Apple Certificates, Identifiers & Profiles page
- Select "App IDs" in the dropdown on the right (if not already selected)
- Click the "+" button next to Identifiers
Configure App ID
- On the Register a New Identifier page, ensure "App IDs" is selected
- Click "Continue"
- On the next page, with "App" selected, click "Continue"
- Fill in the required fields:
- Description: Enter a descriptive name for your app
- Bundle ID: Choose "Explicit" and enter your unique bundle identifier (e.g.,
com.yourcompany.yourapp
)
Enable Sign in with Apple
- Scroll down to the Capabilities section
- Find "Sign In with Apple" in the list and check the box next to it
- Click "Continue" and then "Register"
Step 2: Create a Service ID
Initial Service ID Setup
- Back on the Certificates, Identifiers & Profiles page, use the dropdown and select "Services IDs"
- Click the "+" button next to Identifiers
- On the Register a New Identifier page, ensure "Services IDs" is selected
- Click "Continue"
Configure Service ID
- Fill in the required fields:
- Description: Enter a description for your service
- Identifier: Enter a unique identifier (e.g.,
com.yourcompany.yourapp.service
)
- Click "Continue" and then "Register"
Step 3: Create a Key
Generate Apple Key
- Click on "Keys" in the left navigation menu
- Click the "+" button next to Keys
- Enter a Key Name for identification purposes
Configure Key for Sign in with Apple
- Scroll down and check the box next to "Sign In with Apple"
- Click the "Configure" button beside it
- On the configuration page, select the App ID you created earlier as the Primary App ID
- Click "Save"
Download and Secure Your Key
- Back on the Register a New Key page, click "Continue"
- Click "Register"
- Important: Download the key file (
.p8
format) on the next screen - Store this file securely - Apple only allows you to download it once
- Click "Done"
Step 4: Configure Callback URL
Find Your Convex HTTP Actions URL
- Open your Convex dashboard
- Navigate to Settings > URL & Deploy Key > Show development credentials
- Note your HTTP Actions URL (ends with
.site
, not.cloud
)
Configure Service ID for Web Authentication
- Return to the Certificates, Identifiers & Profiles page
- Use the dropdown to select "Services IDs"
- Click on the Service ID you created earlier
- Ensure "Sign In with Apple" is checked and click "Configure"
Set Up Website URLs
-
In the Domains and Subdomains field, enter just the domain portion of your HTTP Actions URL:
fast-horse-123.convex.site
-
In the Return URLs field, enter your complete callback URL:
https://fast-horse-123.convex.site/api/auth/callback/apple
-
Click "Next"
-
Confirm the values are correct and click "Done"
-
Back on the Services ID configuration page, click "Continue" and then "Save"
Step 5: Generate Apple Client Secret
Gather Required Information
You'll need the following information to generate your Apple client secret:
- Team ID (Account ID): Found in the upper-right corner of Apple Developer Center (10 alphanumeric characters)
- Service ID: The identifier you created for your service (e.g.,
com.yourcompany.yourapp.service
) - Key ID: Found in the filename of your downloaded key file (
AuthKey_XXXXXXXXXX.p8
) - Private Key: The content of your downloaded
.p8
file
Generate JWT Secret
Apple requires a signed JWT token as the client secret. You can use various methods to generate this:
Method 1: Using Online JWT Generator (Recommended for Development)
Use a secure JWT generator that processes data locally in your browser. The JWT should include:
-
Header:
{ "alg": "ES256", "kid": "YOUR_KEY_ID" }
-
Payload:
{ "iss": "YOUR_TEAM_ID", "iat": 1234567890, "exp": 1234567890, "aud": "https://appleid.apple.com", "sub": "YOUR_SERVICE_ID" }
Method 2: Using Node.js (For Production)
const jwt = require('jsonwebtoken');
const fs = require('fs');
const privateKey = fs.readFileSync('path/to/AuthKey_XXXXXXXXXX.p8');
const token = jwt.sign(
{
iss: 'YOUR_TEAM_ID',
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 15777000, // 6 months
aud: 'https://appleid.apple.com',
sub: 'YOUR_SERVICE_ID',
},
privateKey,
{
algorithm: 'ES256',
header: {
kid: 'YOUR_KEY_ID',
},
}
);
console.log(token);
Important: The client secret is valid for a maximum of 6 months. You'll need to regenerate it periodically.
Step 6: Set Convex Environment Variables
Configure Environment Variables
You can set environment variables either via the Convex CLI or through the dashboard.
Option 1: Using Convex CLI (Recommended)
Open your terminal in your Convex application directory and run:
# Set Apple Service ID (Client ID)
npx convex env set AUTH_APPLE_ID your_apple_service_id_here
# Set Apple Client Secret (JWT token)
npx convex env set AUTH_APPLE_SECRET your_generated_jwt_token_here
Option 2: Using Convex Dashboard
- Open your Convex dashboard
- Navigate to Settings > Environment Variables
- Add the following variables:
- Variable Name:
AUTH_APPLE_ID
, Value: Your Apple Service ID - Variable Name:
AUTH_APPLE_SECRET
, Value: Your generated JWT token
- Variable Name:
Note: Apple users can choose to share their name only on the first authentication. The profile configuration above ensures that if the user's name is shared initially, it gets stored and retained for future logins.
Common Issues and Solutions
"Invalid Client" Error
- Verify your Service ID is correctly configured
- Ensure the client secret JWT is properly formatted and signed
- Check that the Service ID matches exactly in both Apple Developer Console and environment variables
"Invalid Redirect URI"
- Verify your callback URL exactly matches:
{HTTP_ACTIONS_URL}/api/auth/callback/apple
- Ensure you're using the production HTTP Actions URL (not localhost)
- Confirm the domain is properly configured in the Service ID settings
"Client Secret Expired"
- Apple client secrets expire after 6 months maximum
- Generate a new JWT token with updated timestamps
- Update your
AUTH_APPLE_SECRET
environment variable
"This App Hasn't Been Verified"
- Ensure your app is properly configured in Apple Developer Console
- For production apps, consider submitting for Apple review
- Verify all required fields are completed in your App ID configuration
SSL Certificate Issues
- Apple requires HTTPS for all production integrations
- Ensure your deployment URL uses a valid SSL certificate
- Test your SSL configuration using online SSL checkers
Security Best Practices
- Secure Key Storage: Store your
.p8
private key securely and never commit it to version control - Regular Secret Rotation: Regenerate your client secret every 6 months or sooner
- Environment Isolation: Use different Apple configurations for development, staging, and production
- Audit Trail: Monitor your Apple Developer Console for any suspicious activity
- Backup Keys: Keep secure backups of your private key files
Support
For additional help:
Secure Apple authentication for your users! 🍎
On This Page
OverviewPrerequisitesStep 1: Create an App IDConfigure App IDEnable Sign in with AppleStep 2: Create a Service IDInitial Service ID SetupConfigure Service IDStep 3: Create a KeyGenerate Apple KeyConfigure Key for Sign in with AppleDownload and Secure Your KeyStep 4: Configure Callback URLFind Your Convex HTTP Actions URLConfigure Service ID for Web AuthenticationSet Up Website URLsStep 5: Generate Apple Client SecretGather Required InformationGenerate JWT SecretMethod 1: Using Online JWT Generator (Recommended for Development)Method 2: Using Node.js (For Production)Step 6: Set Convex Environment VariablesConfigure Environment VariablesOption 1: Using Convex CLI (Recommended)Option 2: Using Convex DashboardCommon Issues and Solutions"Invalid Client" Error"Invalid Redirect URI""Client Secret Expired""This App Hasn't Been Verified"SSL Certificate IssuesSecurity Best PracticesSupport