Skip to content

Modular social logins

Learn how to integrate modular social logins module with Scalekit

Social login enables authentication through existing accounts from providers like Google, Microsoft, and GitHub. Users don’t need to create or remember new credentials, making the sign-in process faster and more convenient. This guide explains how to implement social login in your application with Scalekit’s OAuth 2.0 integration.

How Scalekit works

  1. Use the following instructions to install the SDK for your technology stack.

    npm install @scalekit-sdk/node

    Follow the installation guide to configure Scalekit in your application.

    Go to Dashboard > Authentication > General to turn off the Full-Stack Auth since you’d use the modular social logins module. This disables user management and session management features and let’s to only use social login authentication.

  2. Google login is pre-configured in all development environments for simplified testing. You can integrate additional social login providers by setting up your own connection credentials with each provider.

    Navigate to Authentication > Auth Methods > Social logins in your dashboard to configure these settings

    Google

    Enable users to sign in with their Google accounts using OAuth 2.0

    Set up →

    GitHub

    Allow users to authenticate using their GitHub credentials

    Set up →

    Microsoft

    Integrate Microsoft accounts for seamless user authentication

    Set up →

    GitLab

    Enable GitLab-based authentication for your application

    Set up →

    LinkedIn

    Let users sign in with their LinkedIn accounts using OAuth 2.0

    Set up →

    Salesforce

    Enable Salesforce-based authentication for your application

    Set up →

    After configuration, Scalekit can interact with these providers to authenticate users and verify their identities.

  3. From your application, redirect users to provider’s OAuth pages

    Section titled “From your application, redirect users to provider’s OAuth pages”

    Create an authorization URL to redirect users to social provider’s sign-in page. Use the Scalekit SDK to construct this URL with your redirect URI and provider identifier.

    Supported provider values: google, microsoft, github, salesforce, linkedin, gitlab

    //
    const authorizationURL = scalekit.getAuthorizationUrl(redirectUri, {
    provider: 'google',
    state: state, // recommended
    });
    /*
    https://auth.scalekit.com/authorize?
    client_id=skc_122056050118122349527&
    redirect_uri=https://yourapp.com/auth/callback&
    provider=google
    */

    After the user successfully authenticates with the selected social login provider, they will be redirected back to your application. Scalekit passes an authorization code to your registered callback endpoint, which you’ll use in the next step to retrieve user information.

  4. After successful authentication, Scalekit creates a user record and sends the user information to your callback endpoint.

    1. Add a callback endpoint in your application (typically https://your-app.com/auth/callback)
    2. Register it in your Scalekit dashboard > Authentication > Redirect URLS > Allowed Callback URLs

    In authentication flow, Scalekit redirects to your callback URL with an authorization code. Your application exchanges this code for the user’s profile information and proceed to creating session and logging in the user.

    const { code, state, error, error_description } = req.query;
    if (error) {
    // Handle errors (use error_description if present)
    }
    const authResult = await scalekit.authenticateWithCode(code, redirectUri);
    // authResult.user has the authenticated user's details
    const userEmail = authResult.user.email;
    // Next step: create a session for this user and allow access

    The auth result object

    {
    user: {
    email: "john.doe@example.com" // User's email
    // any additional common fields
    },
    idToken: "<USER_PROFILE_JWT>", // JWT with user profile claims
    accessToken: "<API_CALL_JWT>", // JWT for API calls
    expiresIn: 899 // Seconds until expiration
    }

Your application now supports social login authentication. Users can sign in securely using their preferred social identity providers like Google, GitHub, Microsoft, and more.