Elements Manual
Elements 2 Manual
Elements 2 Manual
  • Welcome 👋
  • QUICK START
    • Elements in Five Minutes or Less
  • General
    • General Concepts
    • N-Tier Architecture
    • Security Model
  • SCRIPTING ENGINE
    • Scripting Engine Overview
      • Intro to Resources and Cloud Functions
      • Horizontal Scaling Model
      • Database Access
      • Server-to-Server API Calls
      • Deploy Cloud Functions via Git
      • Creating and Destroying Resources
      • Cross-Resource Invocation
      • Indexing Resources
      • Coroutines
      • Manifest
  • Core Features
    • Core API Overview
    • Sessions
    • Applications
      • Facebook Application Configuration
      • Firebase Application Configuration
      • Amazon GameOn Application Configuration
      • iOS Application Configuration
      • Android Application Configuration
      • Matchmaking Application Configuration [deprecated]
    • Users and Profiles
    • Digital Goods
    • Progress and Missions
    • Leaderboards
    • Matchmaking
    • Followers
    • Friends
    • Reward Issuance
    • Push Notifications
    • Auth Schemes
    • Save Data
    • Schemas and Metadata Specifications
    • Queries
      • Base Query Syntax
      • Boolean Queries
      • Object Graph Navigation
      • Advanced Operators
        • .ref
        • .name
  • Web 3
    • Omni Chain Support
    • Vaults
    • Wallets
    • Smart Contracts
      • Smart Contracts: Ethereum
      • Smart Contracts: Flow
      • Smart Contracts: Solana
      • Smart Contracts: Neo
    • Know Your Customer
      • Formidium
  • CONFIGURATION
    • Using the Web Console
    • iOS and Android Product Bundles
    • Direct Database Access and Batch Configuration
  • UNITY PLUG-INS
    • Unity Plugin
    • Content Delivery Management and Unity CDN Plugin
  • DEPLOYMENT
    • Deployment Overview
      • Docker Containers
      • AWS Deployment
      • Standalone docker-compose
  • LUA SAMPLES
    • lua Samples
      • main.lua
      • event.lua
      • hello_world.lua
      • model.lua
      • startup.lua
      • HTTP Manifest
        • Example endpoint handler
        • Example operations table
  • RESTful APIs
    • Swagger and Swagger UI
    • Elements 3.0.X (Preview)
      • Applications
      • Friends and Followers
      • Digital Goods and Inventory
      • Leaderboards
      • Missions and Rewards
      • User and Profiles
      • Save Data
      • Custom Metadata
Powered by GitBook
On this page
  • Creation Methods
  • Scoping Rules
  1. Core Features

Sessions

Elements utilizes Sessions in order for the client application to securely communicate with Elements APIs.

PreviousCore API OverviewNextApplications

Last updated 11 months ago

All HTTP requests between the client application and Elements APIs can have a session key. Creating a Session may be completed through several API calls. There are multiple ways to create a session as detailed in this document.

Elements recognizes the following session headers:

  • Authorization: [bearer] {secret}

  • secret (Required): The Session secret (See below for more information.)

  • Elements-SessionSecret: {secret} [u{UserId}] [p{ProfileId}]

  • secret (Required): The Session secret (See below for more information.)

  • userId (Optional): The id of a User. If the secret matches a Super User then this may be any other non Super User in Elements. This will cause the subsequent request to be executed as the specified User. For all other Users, this must be the identity associated with the session making the request. This will override the User .

  • profileId (Optional): The id of a Profile. If the secret matches a Super User then this may be any Profile in Elements. For all other Users, this must be a Profile associated with the User making the request. Ths will override the .

Creation Methods

There are several ways to create sessions within Elements. Each section here describes the supported creation methods and how to implement each one of them. In all cases, Elements performs the account verification authoritatively, ensuring that the server has verified the credentials supplied to it.

Username and Password

This the most basic method of creating a session and requires no third-party integration. When creating a User, the client supplies the desired username and password. Elements securely hashes each User's password in the database.

Facebook

Elements supports login using Facebook OAuth tokens. When passing an OAuth token to Elements, Elements will verify the token and create an account for the user based on the information supplied by Facebook. To support Facebook login, Elements requires additional configuration in the admin panel.

The Facebook Sign-In Procedure is as follows:

  1. Configure a new or select an existing Application.

  2. Configure a

  3. Install the appropriate for your platform of choice.

  4. Using the Elements RESTful API, submit the following information to Elements:

    • applicationNameOrId: The or the of the Application

    • applicationConfigurationNameOrId: The or the of the Application

    • facebookOAuthAccessToken: The supplied by the Facebook SDK.

    • Note: We recommend using a token, but any token will work.

  5. Elements will respond with information about the User, Session, and other information.

    • Note: This process will also automatically synchronize Facebook friends with

TODO: Add detail on lua code samples to get this running

Apple Sign-In

Per Apple's requirements, Elements supports session creation via Apple Sign-In. This ensures that Apple users may sign in and link their Elements account to their Apple account. This requires additional configuration in the Elements admin panel.

The Apple Sign-In procedure is as follows:

  1. Using the Elements RESTful API, submit the following to Elements:

  2. Elements will respond with information about the User, Session, and other information.

TODO: Add detail on lua code samples to get this running

Firebase

  1. Using hte Elements RESTful API, submit the JWT generated by the Firebase SDK to Elements.

  2. Elements will verify the JWT aginst Firebase's servers as well as create an account within Elements based on the information provided.

    • Note: The claims in the JWT will contain everything necessary to authorize the application.

Scoping Rules

User

All sessions will have a User associated with them. Once created, they will always be valid for that User until it expires or the user changes their password.

Profile

A Session may, optionally, be scoped by a User and a Profile. The Profile's owner must match the User who created the session. APIs that require Profile scoping rules are as follows:

  • Fetching current Profile (eg GET /profile/current)

  • Processing IAPs

  • Leaderboards and Rankings

  • Push Notifications

  • Progress and Missions

Configure a new or select an existing Application.

Configure an

Configure your iOS App for

Using the Apple SDK obtain an instance of

applicationNameOrId: The or the of the Application

applicationConfigurationNameOrId: The or of the Application

identityToken: The supplied by Apple.

authCode: The supplied by Apple.

Elements supports using generated by the Firebase SDK. Firebase supports a myriad of logins for a variety of platforms. By integrating Firebase, Elements can support all login schemes offered by Firebase without any additional configuration.

Configure a new or select an existing Application.

Configure a .

Integrate the into your application or site.

If using Firebase, we do not recommend mixing other auth strategies other than .

Within the Elements , sessions may have two scopes: User or Profile. Some APIs require a session with a current Profile and not just a User. Generally these APIs are for application specific operations, such as Matchmaking.

Application
Apple Sign-In
ASAuthorizationAppleIDCredential
identityToken
authorizationCode
Firebase Authentication
JWTs (Javascript Web Tokens)
Application
Firebase Application Configuration
Firebase SDK
Security Model
Username and Password
Application
Facebook SDK
Android
iOS
JavaScript
PHP
tvOS
Unity
OAuth Access Token
short-lived
Elements Friends
Creation Methods
Creation Methods
Scoping Rules
Profile Scoping Rules
id
name
id
name
id
name
id
name
Facebook Application Configuration
Apple Sign-In Configuration