Skip to content
Scalekit Docs
Talk to an EngineerDashboard

Initiate user signup or login

Create authorization URLs and redirect users to Scalekit's hosted login page

Login initiation begins your authentication flow. You redirect users to Scalekit’s hosted login page by creating an authorization URL with appropriate parameters.When users visit this URL, Scalekit’s authorization server validates the request, displays the login interface, and handles authentication through your configured connection methods (SSO, social providers, Magic Link or Email OTP

Authorization URL format
<SCALEKIT_ENVIRONMENT_URL>/oauth/authorize?
response_type=code& # always `code` for authorization code flow
client_id=<SCALEKIT_CLIENT_ID>& # Dashboard > Developers > Settings > API Credentials
redirect_uri=<CALLBACK_URL>& # Dashboard > Authentication > Redirect URLs > Allowed Callback URLs
scope=openid+profile+email+offline_access& # Permissions requested. Include `offline_access` for refresh tokens
state=<RANDOM_STATE> # prevent CSRF attacks

The authorization request includes several parameters that control authentication behavior:

  • Required parameters ensure Scalekit can identify your application and return the user securely
  • Optional parameters enable organization routing and pre-populate fields
  • Security parameters prevent unauthorized access attempts

Understand each parameter and how it controls the authorization flow:

Query parameterDescription
response_typeSet to code for authorization code flow Required
Indicates the expected response type
client_idYour application’s public identifier from the dashboard Required
Scalekit uses this to identify and validate your application
redirect_uriYour application’s callback URL where Scalekit returns the authorization code Required
Must be registered in your dashboard settings
scopeSpace-separated list of permissions Required
Always include openid profile email. Add offline_access to request refresh tokens for extended sessions
stateRandom string generated by your application Recommended
Scalekit returns this unchanged. Use it to prevent CSRF attacks and maintain request state
promptValue to control the authentication flow Optional
Use login to force re-authentication even when the user has a valid session. Send it only when you need to re-verify identity — including it on routine logins re-prompts users unnecessarily, a common cause of users appearing logged out
Use create to trigger the sign-up page
Use select_account to force the organization selector, even if the user has an active session with an organization. The selector appears only when the user belongs to multiple organizations
Use none to check silently whether a session exists, without showing the login or sign-up page
organization_idSkip routing the user to the hosted login page and route them to the enterprise SSO connection configured for the organization Optional
connection_idSkip routing the user to the hosted login page and route them to a specific enterprise SSO connection Optional
login_hintUsed for Home Realm Discovery. Scalekit extracts the email domain from login_hint and routes the user to the matching organization’s SSO connection based on configured domain rules Optional
providerSkip routing user to hosted login page and direct user to a specific social connection. Supported values: google, microsoft, github, gitlab, linkedin, and salesforce Optional
  1. Add state parameter recommended

    Section titled “Add state parameter ”

    Always generate a cryptographically secure random string for the state parameter and store it temporarily (session, local storage, cache, etc).

    This can be used to validate that the state value returned in the callback matches the original value you sent. This prevents CSRF (Cross-Site Request Forgery) attacks where an attacker tricks users into approving unauthorized authentication requests.

    Generate and store state
    // Generate secure random state
    const state = require('crypto').randomBytes(32).toString('hex');
    // Store it temporarily (session, local storage, cache, etc)
    sessionStorage.oauthState = state;
  2. Use the Scalekit SDK to generate the authorization URL. This method constructs the URL locally without making network requests. Redirect users to this URL to start authentication.

    Express.js
    4 collapsed lines
    import { Scalekit } from '@scalekit-sdk/node';
    const scalekit = new Scalekit(/* your credentials */);
    // Basic authorization URL for general login
    const redirectUri = 'https://yourapp.com/auth/callback';
    const options = {
    scopes: ['openid', 'profile', 'email', 'offline_access'],
    state: sessionStorage.oauthState,
    };
    const authorizationUrl = scalekit.getAuthorizationUrl(redirectUri, options);
    // Redirect user to Scalekit's hosted login page
    res.redirect(authorizationUrl);

    Scalekit will try to verify the user’s identity and redirect them to your application’s callback URL. If the user is a new user, Scalekit will automatically create a new user account.

To keep sign-up separate from login, use the prompt: 'create' parameter to send users straight to the dedicated sign-up page.

Express.js
const redirectUri = 'http://localhost:3000/api/callback';
const options = {
scopes: ['openid', 'profile', 'email', 'offline_access'],
prompt: 'create', // explicitly takes you to sign up flow
};
4 collapsed lines
const authorizationUrl = scalekit.getAuthorizationUrl(redirectUri, options);
res.redirect(authorizationUrl);

After the user authenticates either in signup or login flows:

  1. Scalekit generates an authorization code
  2. Makes a callback to your registered allowed callback URL
  3. Your backend exchanges the code for tokens by making a server-to-server request

This approach keeps sensitive operations server-side and protects your application’s credentials.

Let’s take a look at how to complete the login in the next step.