Authentication Setup
Scope requirements
Ensure your OAuth scopes include openid, email, and profile, plus any project-specific audience scopes. Missing scopes may prevent token-based access.
🔐 Authentication Setup Guide
Overview
Tech231 Platform uses Zitadel as its identity provider, implementing OAuth 2.0 and OpenID Connect for secure authentication. This guide walks you through setting up authentication for both service accounts (API access) and user accounts (application access).
Authentication Endpoint
All authentication requests go through:
Code
Authentication Types
Service Accounts
Best for: Server-to-server API integration, automated systems, backend services
- Uses OAuth2 Client Credentials flow
- No user interaction required
- Long-lived access tokens
- Ideal for programmatic API access
User Accounts
Best for: Web applications, mobile apps, interactive dashboards
- Uses OAuth2 Authorization Code flow
- Requires user login
- Supports refresh tokens
- Multi-factor authentication (MFA) support
Setting Up a Service Account
Prerequisites
Before you begin, ensure you have:
- An active Tech231 Platform organization account
- Admin or Owner role in your organization
- Access to Zitadel at
https://auth.tech231apps.net
Step 1: Log Into Zitadel
- Navigate to
https://auth.tech231apps.net - Click "Sign In"
- Enter your credentials
- Complete two-factor authentication (if enabled)
Step 2: Access Your Organization
- After logging in, click on your profile icon (top right)
- Select your organization from the dropdown
- You'll be redirected to your organization's home page
Step 3: Create a Service User
-
Click on "Users" in the left sidebar
-
Switch to the "Service Users" tab
-
Click "New" or "Create Service User"
-
Fill in the service user details:
- Username: A descriptive name (e.g.,
production-api-service,sms-integration-bot) - Name: Human-readable display name
- Description: Purpose of this service account
- Username: A descriptive name (e.g.,
-
Important: Set the Access Token Type to JWT
- This is required for the Tech231 Platform API
- Without JWT tokens, API requests will fail
-
Click "Create"
Step 4: Generate Client Credentials
-
After creating the service user, click on it to view details
-
Navigate to the "Actions" or "Client Secret" section
-
Click "New" to generate a client secret
-
Important: Copy the following immediately (they won't be shown again):
- Client ID: Your service account identifier (starts with
@) - Client Secret: Your service account password
- Client ID: Your service account identifier (starts with
-
Store these credentials securely:
Code
Step 5: Verify API Access
-
Click on "Projects" in the left sidebar
-
Select "Granted Projects"
-
Verify you see the Tech231 APIs:
- SMS API
- USSD API (if applicable)
- Any other services you need
-
If APIs are missing:
- Contact support at
support@tech231apps.net - Request access to the specific APIs you need
- Include your organization name and use case
- Contact support at
Step 6: Authorize the Service User
- Go to "Projects" → "Granted Projects"
- Click on the SMS project (or relevant API)
- Navigate to "Authorizations"
- Click "New Authorization"
- Select your service user from the dropdown
- Configure the authorization:
- Roles: Select roles needed (e.g.,
SMS.Send,SMS.Read) - Scopes: Platform will automatically include required scopes
- Roles: Select roles needed (e.g.,
- Click "Save"
Step 7: Test Your Credentials
Test authentication using curl:
Code
Expected Response:
Code
Setting Up User Authentication
For applications that require user login (web apps, mobile apps), implement the OAuth2 Authorization Code flow.
Step 1: Register Your Application
-
In Zitadel, go to "Projects" → "Granted Projects"
-
Select the Tech231 platform project
-
Navigate to "Applications"
-
Click "New Application"
-
Choose "Web" or "Native" depending on your app type
-
Configure:
- Name: Your application name
- Authentication Method:
- Code (Authorization Code flow - recommended)
- PKCE (for mobile/SPA apps)
- Redirect URIs: Your callback URLs (e.g.,
https://yourapp.com/auth/callback) - Post Logout Redirect URIs: Where users go after logout
-
Click "Create"
-
Copy your Client ID (and Client Secret if applicable)
Step 2: Implement Authorization Flow
Authorization Request
Redirect users to the authorization endpoint:
Code
Parameters:
client_id: Your application's client IDredirect_uri: Must match a registered redirect URIresponse_type: Alwayscodefor Authorization Code flowscope: Space-separated list of required scopesstate: Random value to prevent CSRF attacks
Token Exchange
After user authorizes, they're redirected back with a code:
Code
Exchange the code for tokens:
Code
Response:
Code
Step 3: Refresh Tokens
When access tokens expire, use the refresh token:
Code
Required Scopes
Include these scopes in your authentication requests:
| Scope | Description | Required For |
|---|---|---|
openid | OpenID Connect authentication | All requests |
email | Access to user's email address | User info |
profile | Access to user profile information | User info |
offline_access | Request refresh token | Long-lived sessions |
urn:zitadel:iam:org:project:id:321914919689650215:aud | Tech231 platform resource scope | API access |
urn:zitadel:iam:user:resourceowner | Resource owner information | Multi-tenant apps |
Minimum required scopes for API access:
Code
Understanding JWT Tokens
Token Structure
Tech231 Platform uses JWT (JSON Web Tokens) for authentication. A typical token contains:
Header:
Code
Payload (Claims):
Code
Key Claims:
iss: Token issuer (Zitadel instance)sub: Subject (user/service account ID)aud: Audience (platform project ID)exp: Expiration timestampazp: Authorized party (client ID)urn:zitadel:iam:org:id: Your organization/tenant IDurn:zitadel:iam:org:project:id:...:roles: Assigned roles
Tenant Context
Important: Your tenant context is automatically determined from the JWT token's organization claims. You do NOT need to send additional headers like X-Tenant-ID.
The platform extracts your tenant from:
Code
This ensures complete tenant isolation and security.
Security Best Practices
Credential Management
-
Never commit secrets to version control
- Use environment variables
- Use secret management tools (AWS Secrets Manager, Azure Key Vault, etc.)
- Add
.envfiles to.gitignore
-
Rotate credentials regularly
- Change service account secrets every 90 days
- Rotate immediately if compromised
- Use multiple service accounts for different services
-
Use appropriate authentication method
- Service accounts for backend APIs
- User accounts for interactive applications
- Never use user credentials in automated systems
Token Management
-
Store tokens securely
- Use secure, HTTP-only cookies for web apps
- Use encrypted storage for mobile apps
- Never store in localStorage or sessionStorage
-
Implement token refresh
- Refresh before expiration (not after)
- Handle refresh failures gracefully
- Redirect to login if refresh fails
-
Validate tokens
- Verify signature using Zitadel's public keys
- Check expiration (
expclaim) - Validate audience (
audclaim) - Verify issuer (
issclaim)
Network Security
-
Always use HTTPS
- Never send tokens over HTTP
- Validate SSL certificates
- Use certificate pinning for mobile apps
-
Implement rate limiting
- Prevent brute force attacks
- Limit token requests per IP
- Monitor suspicious activity
Troubleshooting
"Invalid Client" Error
Cause: Client ID or secret is incorrect
Solution:
- Verify client ID matches exactly (including the
@organizationsuffix) - Regenerate client secret if lost
- Check for extra spaces or line breaks in credentials
"Invalid Scope" Error
Cause: Requesting scopes not granted to your organization
Solution:
- Verify granted projects in Zitadel
- Request correct platform resource scope
- Contact support to grant additional scopes
"Unauthorized" (401) Errors
Cause: Token expired or invalid
Solution:
- Check token expiration (
expclaim) - Implement token refresh
- Verify token is included in
Authorizationheader - Ensure format is
Bearer <token>
"Forbidden" (403) Errors
Cause: Insufficient permissions
Solution:
- Check service user has required roles
- Verify authorization in Zitadel project
- Review role assignments
- Contact admin to grant necessary permissions
Token Not Working After Generation
Cause: Service user not authorized for platform APIs
Solution:
- Go to Projects → Granted Projects → SMS
- Check Authorizations
- Add authorization for your service user
- Include necessary roles
Code Examples
Node.js (Express)
Code
Python
Code
C# (.NET)
Code
Next Steps
- Test your authentication with the provided code examples
- Implement token refresh for long-running applications
- Set up error handling for authentication failures
- Review security best practices and implement them
- Monitor your API usage in the dashboard
Support
Need help with authentication setup?
- 📚 Documentation: OAuth 2.0 Guide
- 💬 Support Chat: Available in your dashboard
- 📧 Email: support@tech231apps.net
- 🎥 Video Tutorial: Watch the setup guide
Ready to authenticate? Create your service account now →