gRPC Authentication

📦v1.0.0📅2026-03-10🔄Updated 2026-04-28👤Admin Team
developergrpcprotobufauthenticationapi

This section describes the gRPC interface of the messaging platform.

The gRPC API provides high-performance access to authentication and SMS messaging functionality. It is intended for internal services and high-throughput clients.

The API exposes two main services:

  • Auth Service — user management and authorization (this page)
  • SMS Service — message submission and delivery tracking (gRPC Messaging)

gRPC Transport

The gRPC server accepts connections over HTTP/2.

ParameterValue
ProtocolgRPC (HTTP/2)
Default Port44044
TLSDisabled by default (plaintext)
TimeoutConfigurable via grpc.timeout in config_local.yaml (default: 1h)

Example endpoint:

127.0.0.1:44044

Authentication

All protected gRPC endpoints require authentication via metadata headers.

The following metadata must be provided with each request:

HeaderTypeRequiredDescription
authorizationstringYesBearer JWT token obtained from Login
app_idstringYesNumeric application identifier assigned during registration

Example metadata:

authorization: Bearer eyJhbGciOiJIUzI1NiIs...
app_id: 1

Obtaining a Token

Tokens are obtained through the Login RPC:

grpcurl \
  -plaintext \
  -d '{"app_id":1,"email":"admin@example.com","password":"password"}' \
  '127.0.0.1:44044' \
  auth.Auth.Login

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIs..."
}

The token must be included in all subsequent gRPC calls. Tokens expire after the duration configured in security.token_ttl (default: 12 hours).


Testing with grpcurl

The gRPC API can be tested using grpcurl.

Example request with authentication:

grpcurl \
  -plaintext \
  -H 'authorization: Bearer <jwt-token>' \
  -H 'app_id: 1' \
  -emit-defaults \
  -d '{"text":"example message"}' \
  127.0.0.1:44044 \
  sms.v1.SmsService/CheckTextLen

Auth Service

Authentication service responsible for user management and authorization.

Service name:

auth.Auth

Register

Registers a new user account.

rpc Register(RegisterRequest) returns (RegisterResponse)

Request Fields

FieldTypeRequiredDescription
emailstringYesUnique email address for the new account
passwordstringYesAccount password
{
  "email": "user@example.com",
  "password": "secure-password"
}

Response Fields

FieldTypeDescription
user_idint64Unique identifier assigned to the new user. Also used as app_id for API access
{
  "user_id": 1
}

Errors

gRPC CodeCondition
INVALID_ARGUMENTMissing or invalid email/password
ALREADY_EXISTSEmail address is already registered

Login

Authenticates a user and returns a JWT token.

rpc Login(LoginRequest) returns (LoginResponse)

Request Fields

FieldTypeRequiredDescription
emailstringYesRegistered email address
passwordstringYesAccount password
app_idint64YesApplication identifier (same as user_id from registration)
{
  "email": "admin@example.com",
  "password": "password",
  "app_id": 1
}

Response Fields

FieldTypeDescription
tokenstringJWT token for authenticating subsequent requests
{
  "token": "eyJhbGciOiJIUzI1NiIs..."
}

Errors

gRPC CodeCondition
UNAUTHENTICATEDInvalid email, password, or app_id

IsAdmin

Checks whether a user has administrator privileges.

rpc IsAdmin(IsAdminRequest) returns (IsAdminResponse)

Request Fields

FieldTypeRequiredDescription
user_idint64YesUser identifier to check
{
  "user_id": 1
}

Response Fields

FieldTypeDescription
is_adminbooltrue if the user has admin privileges
{
  "is_admin": true
}

DeleteUser

Removes a user account from the system.

rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse)

Request Fields

FieldTypeRequiredDescription
user_idint64YesUser identifier to delete
{
  "user_id": 3
}

Response Fields

FieldTypeDescription
resultbooltrue if the user was successfully deleted
{
  "result": true
}

Errors

gRPC CodeCondition
NOT_FOUNDUser with the specified ID does not exist

gRPC Error Codes

The platform uses standard gRPC status codes. Common codes across all endpoints:

gRPC CodeHTTP EquivalentDescription
OK200Request succeeded
INVALID_ARGUMENT400Malformed request or missing required fields
UNAUTHENTICATED401Missing or invalid JWT token, missing app_id metadata
PERMISSION_DENIED403Client IP not in whitelist, or insufficient privileges
NOT_FOUND404Requested resource does not exist
ALREADY_EXISTS409Duplicate resource (e.g., email already registered)
RESOURCE_EXHAUSTED429Rate limit exceeded
INTERNAL500Server-side error (SMPP failure, storage error)
UNAVAILABLE503Service temporarily unavailable

Error responses include a human-readable message field describing the specific failure.


Service Summary

ServiceMethodDescription
AuthRegisterRegister a new user account
AuthLoginAuthenticate and obtain JWT token
AuthIsAdminCheck administrator privileges
AuthDeleteUserRemove a user account