Skip to content

Quick Start

This guide will help you integrate AuthStack into your application quickly.

  • A AuthStack account
  • Your application registered in the AuthStack dashboard
  • OAuth providers configured and enabled for your app
  1. Log in to the AuthStack Dashboard
  2. Create a new application
  3. Copy your Client ID
  4. Enable the OAuth providers you want to use (Google, GitHub, Microsoft, Apple, Discord)
Terminal window
flutter pub add voostackauth_client
Terminal window
npm install @voostack/auth
import 'package:voostackauth_client/voostackauth_client.dart';
final authClient = AuthStackClient(
baseUrl: 'https://api.authstack.voostack.com',
clientId: 'your-client-id',
);
import { AuthStack } from '@voostack/auth';
const auth = new AuthStack({
baseUrl: 'https://api.authstack.voostack.com',
clientId: 'your-client-id',
});
// Get Google credential
final googleUser = await GoogleSignIn().signIn();
final googleAuth = await googleUser.authentication;
// Exchange for AuthStack tokens
final response = await authClient.loginWithProvider(
provider: OAuthProvider.google,
token: googleAuth.idToken,
);
if (response.isSuccess) {
await storage.saveTokens(response.tokens);
}
// After OAuth redirect with authorization code
final response = await authClient.loginWithProvider(
provider: OAuthProvider.github,
code: authorizationCode,
redirectUri: 'https://yourapp.com/oauth/callback',
);
// Microsoft
await authClient.loginWithProvider(
provider: OAuthProvider.microsoft,
code: authorizationCode,
redirectUri: redirectUri,
);
// Apple
await authClient.loginWithProvider(
provider: OAuthProvider.apple,
token: identityToken,
);
// Discord
await authClient.loginWithProvider(
provider: OAuthProvider.discord,
code: authorizationCode,
redirectUri: redirectUri,
);
final response = await authClient.login(
email: 'user@example.com',
password: 'password123',
);
if (response.isSuccess) {
await storage.saveTokens(response.tokens);
}

Use the tokens to authenticate API requests:

final dio = Dio();
dio.options.headers['Authorization'] = 'Bearer ${tokens.accessToken}';