Quick Start
This guide will help you integrate AuthStack into your application quickly.
Prerequisites
Section titled “Prerequisites”- A AuthStack account
- Your application registered in the AuthStack dashboard
- OAuth providers configured and enabled for your app
1. Get Your Credentials
Section titled “1. Get Your Credentials”- Log in to the AuthStack Dashboard
- Create a new application
- Copy your Client ID
- Enable the OAuth providers you want to use (Google, GitHub, Microsoft, Apple, Discord)
2. Install the SDK
Section titled “2. Install the SDK”Flutter
Section titled “Flutter”flutter pub add voostackauth_clientnpm (React/Vue)
Section titled “npm (React/Vue)”npm install @voostack/auth3. Initialize the Client
Section titled “3. Initialize the Client”Flutter
Section titled “Flutter”import 'package:voostackauth_client/voostackauth_client.dart';
final authClient = AuthStackClient( baseUrl: 'https://api.authstack.voostack.com', clientId: 'your-client-id',);JavaScript
Section titled “JavaScript”import { AuthStack } from '@voostack/auth';
const auth = new AuthStack({ baseUrl: 'https://api.authstack.voostack.com', clientId: 'your-client-id',});4. Implement Social Login
Section titled “4. Implement Social Login”Google Sign-In
Section titled “Google Sign-In”// Get Google credentialfinal googleUser = await GoogleSignIn().signIn();final googleAuth = await googleUser.authentication;
// Exchange for AuthStack tokensfinal response = await authClient.loginWithProvider( provider: OAuthProvider.google, token: googleAuth.idToken,);
if (response.isSuccess) { await storage.saveTokens(response.tokens);}GitHub Login
Section titled “GitHub Login”// After OAuth redirect with authorization codefinal response = await authClient.loginWithProvider( provider: OAuthProvider.github, code: authorizationCode, redirectUri: 'https://yourapp.com/oauth/callback',);Other Providers
Section titled “Other Providers”// Microsoftawait authClient.loginWithProvider( provider: OAuthProvider.microsoft, code: authorizationCode, redirectUri: redirectUri,);
// Appleawait authClient.loginWithProvider( provider: OAuthProvider.apple, token: identityToken,);
// Discordawait authClient.loginWithProvider( provider: OAuthProvider.discord, code: authorizationCode, redirectUri: redirectUri,);5. Email/Password Login
Section titled “5. Email/Password Login”final response = await authClient.login( email: 'user@example.com', password: 'password123',);
if (response.isSuccess) { await storage.saveTokens(response.tokens);}6. Protect Routes
Section titled “6. Protect Routes”Use the tokens to authenticate API requests:
final dio = Dio();dio.options.headers['Authorization'] = 'Bearer ${tokens.accessToken}';Next Steps
Section titled “Next Steps”- Installation - Detailed installation guide
- Concepts - Understand tokens and sessions
- OAuth 2.0 Authorization - Implement OAuth flows with PKCE
- Applications API - Manage OAuth applications