Hey there! Welcome to the Austin SDK authentication helper. This little library makes it super easy to connect your Node.js apps with our awesome auth system.
If you're building an app that needs to authenticate users through auth, this SDK handles all the OAuth for you.
First, grab the package:
npm install @austinsdk/authThen you're ready to go:
const Auth = require('@austinsdk/auth');
// Set up your auth client with your app's credentials
const auth = new Auth(
'https://auth.austinsdk.me', // The auth server URL
'your-client-id', // Your app's client ID
'your-client-secret', // Your app's client secret (keep this safe!)
'https://yourapp.com/callback' // Where users get sent after auth
);When someone wants to log into your app, redirect them to the auth URL:
// This creates a URL that sends users to Austin's login page
const authUrl = auth.getAuthUrl();
// Optional: use a different redirect URL for this specific request
const customAuthUrl = auth.getAuthUrl('https://yourapp.com/special-callback');
console.log('Send your user here:', authUrl);After users log in, they'll be redirected back to your app with a special code. Trade that code for an access token:
// Assuming you got the code from the URL parameter
const code = 'the-code-from-the-redirect';
try {
const tokenResponse = await auth.codeForToken(code);
console.log('Got a token!', tokenResponse.access_token);
} catch (error) {
console.log('Oops, something went wrong:', error);
}Now you can get user info and their projects:
const token = tokenResponse.access_token;
// Get info about the logged-in user
const userInfo = await auth.getUserInfo(token);
console.log('Hello,', userInfo.name || userInfo.username);
// Get their projects
const projects = await auth.getProjects(token);
console.log(`You have ${projects.length} projects!`);
// Check if the token is still valid
const verification = await auth.verify(token);
if (verification.valid) {
console.log('Token looks good!');
} else {
console.log('Time to refresh that token...');
}Creates a new authentication client.
- url: The base URL for Austin's auth server
- client_id: Your application's client ID
- client_secret: Your application's client secret (keep this secure!)
- redirect_uri: Where users should be sent after authentication
Returns the URL to send users to for authentication.
- redirect_uri (optional): Override the default redirect URI
Exchanges an authorization code for an access token.
- code: The authorization code from the callback
- redirect_uri (optional): Must match the one used in getAuthUrl
Gets information about the authenticated user.
- token: The access token
Gets the user's projects.
- token: The access token
Checks if a token is valid.
- token: The access token to verify
- Node.js 14 or higher
- An application registered with Austin's platform
Something not working? Found a bug? Have a question?
- Open an issue
- Check out the Austin SDK documentation
MIT License - feel free to use this in your projects!
Made with ❤️ by Austin's SDK