Momen Docs
Go to Momen
  • Get Started
    • Introduction
    • Quick Start
    • Software Development Process
    • Editor Overview
  • Changelog
    • Latest Product Update
  • Build UI
    • Pages
    • Components
    • Canvas
    • Layout
    • Component - Display
    • Component - Input
    • Component - View
    • Component - List
    • Component - Tab View
    • Component - Select View
    • Component - Conditional View
    • Component - Others
    • Component - Map
    • Custom Component
  • Data
    • Overview
    • Data Model and Database
    • API
    • Variable
    • Parameter
    • Formula and Conditions
  • Actions
    • Overview
    • Request
    • Navigation
    • Actionflow
      • Custom Code
      • Database Trigger
    • AI
      • AI Data Model
      • AI Point
      • Vector Data Storage and Sorting
    • User Actions
    • Component Management
    • App and Page Management
    • Toast Notifications & Modal
    • Payment
    • SSO
    • Share
    • Location
    • File Management
    • QR Code
    • Clipboard
    • Conditional
    • Loop
  • Release and Growth
    • Publish Application
    • Upgrade Project
    • Multiple Clients
    • Permission
    • Log Service
    • SEO
    • Hosting Files
  • My Account and Community
    • My Wallet
    • Promoting Momen
    • Code Component
    • Collaboration
  • Debugging
    • How to Debug in Momen
    • Request Error Reference
  • Tutorial
    • How to Build an AI Needs Analysis Project?
    • How to Set Up Payment with Stripe Plugin?
    • How to Embed an Iframe Component into Your Momen Project?
    • How to Build Your Login Page?
    • How to Convert Momen App to Native Mobile App?
    • How to Build a CMS (MVP Version) in Hours?
    • How to Set a Countdown Timer When Sending a Verification Code
  • Template
    • AI Mental Health Assistant
    • Angry Dietitian
    • AI Help Center
    • AI Knowledge Base
    • SaaS Corporate Site
    • Blog
    • AI Feedback Tool
    • Feedback Tool, a Nod to Canny
    • Portfolio
    • Online Courses, a Nod to Udemy
    • Mobile Auto Repair AI Scheduler
Powered by GitBook
On this page
  • What is Single Sign-On (SSO)?
  • Benefits of Single Sign-On
  • Steps to Configure SSO
  • 1. Create an SSO Configuration in Momen
  • 2. Register an Application with an Identity Provider (e.g., Google)
  • 3. Fill in Application Information in Momen
  • 4. Configure Actions
  • Consume SSO User Information
  1. Actions

SSO

Learn how to configure Single Sign-On (SSO) in Momen to enhance user experience, improve security, and simplify access management for your applications.

What is Single Sign-On (SSO)?

Single Sign-On (SSO) is an authentication mechanism that allows users to access multiple related systems with a single login. By configuring SSO, new users can register and log in to your website using existing accounts (e.g., Google, Facebook, etc.).

  • Only supports the standard OAuth2 protocol

  • Available for Pro Plan and above

Benefits of Single Sign-On

  • Improved User Experience: Users only need to log in once to access multiple applications, reducing repetitive login operations.

  • Enhanced Security: By centralizing access management, SSO is more secure than traditional username and password authentication.

  • Simplified Management: Enterprises can simplify the management of multiple applications through SSO.

Steps to Configure SSO

1. Create an SSO Configuration in Momen

  • Open project settings, find "Login - SSO," and click "Add."

  • The system will automatically generate a callback URL for redirection after successful authorization.

2. Register an Application with an Identity Provider (e.g., Google)

  1. Create a new project and fill in the project information.

  2. Enable APIs and services in the project and set up the OAuth consent screen.

  3. Configure the privacy policy and terms of service pages.

  4. Set up the OAuth client ID and fill in the callback URL.

  5. Obtain the client ID and client secret.

3. Fill in Application Information in Momen

  • Enter the client ID, client secret, and scope.

  • Save the configuration and enable SSO.

4. Configure Actions

  • Register/Login: After authorization, log in if the account exists; otherwise, register a new user.

  • Bind Existing Account: Bind the authorized account to the currently logged-in account.

  • Unbind Account: Unbind the current account from the SSO.

Consume SSO User Information

As an example of updating the user's "email" information:

  1. Add an email field to the account table.

  2. Add the following code to the action flow to update the username and email in the account table:

function updateAccount(variables) {
    const gql = `mutation updateAccount(
          $accountId: bigint
          $email: String
          $name: String
        ) {
          update_account(
            _set: { email: $email, username: $name }
            where: { id: { _eq: $accountId } }
          ) {
            returning {
              id
              username
            }
          }
        }
        `;
    return context.runGql("updateAccount", gql, variables, {
      role: "admin",
    }).update_account;
  }
  function queryAccount(variables) {
    const gql = `query queryAccount($accountId: bigint) {
          account(where: { id: { _eq: $accountId } }, limit: 1) {
            id
            username
          }
        }
          `;
    return context.runGql("queryAccount", gql, variables, {
      role: "admin",
    }).account[0];
  }
  
  const accountId = context.getSsoAccountId();
  
  const queryAccountResult = queryAccount({ accountId });
  
  if (queryAccountResult.username === null) {
    const userInfo = context.getSsoUserInfo();
    const userInfoJson = JSON.parse(userInfo);
    const name = userInfoJson.username;
    const email = userInfoJson.email;
    const updateAccountVariables = {
      accountId,
      email,
      name,
    };
  
    const updateAccountResult = updateAccount(updateAccountVariables);
  }
PreviousPaymentNextShare

Last updated 1 day ago

Register as a Google Developer: .

Google Cloud Console