Skip to main content

17

Client credentials

Client credentials in Studio can be used to access Mobile endpoints without using username/password.

An example would be the execution of a manual trigger of an entity:

<Entity Id="Entity1" Key="id" SyncType="Automatic" Table="table1">
  <Entity.Triggers>
    <Trigger Id="EchoTrigger" Type="EchoTrigger" Method="Manual" />
  </Entity.Triggers>
    <Field Name="id" Type="Guid" IsRequired="True" />
    <Field Name="name" Type="String" MaxLength="256" />
    <Field Name="geometry" Type="Geometry" />
    <Field Name="lastupdatetime" Type="DateTime" />
</Entity>
using AppShell.Services.Core;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SampleTriggers
{
    [Trigger(nameof(EchoTrigger))]
    public class EchoTrigger : ITrigger
    {
        public async Task> ExecuteAsync(TriggerContext context)
        {
            Dictionary result = new Dictionary();

            foreach (KeyValuePair value in context.Values)
                result.Add(value.Key, $"Echo: {value.Value}");

            return result;
        }
    }
}

Retrieve an access token from client credentials you have defined in Studio:

POST Mobile/token HTTP/1.1
Host: <Host>
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=<ClientId>&client_secret=<ClientSecret>

Execute EchoTrigger from Entity1 with the retrieved access token:

POST Mobile/api/v1/apps/<AppName>/entities/Entity1/triggers/EchoTrigger HTTP/1.1
Host: <Host>
Authorization: Bearer <AccessToken>
Content-Type: application/json

{
  "key1": "value1",
  "key2": "value2"
}

The result of the previous HTTP request should look like this:

{
  "key1": "Echo: value1",
  "key2": "Echo: value2"
}
Updated on Aug 10, 2026