Metaplay Authen API
🔠Metaplay • Authentication

Metaplay Authen API

Standardized authentication API for Metaplay apps: login, refresh tokens, revoke sessions, and OAuth2/JWT validation.

Base URL
https://api.metaplay.example.com/auth
General Requirements
  • Content-Type: application/json
  • Response: JSON
  • Token standard: JWT, signed with RS256

POST /login

Login with email/phone number & password.

{ "username": "user@example.com", "password": "••••••••", "scope": "openid profile offline_access" }

Returns: access_token (15 minutes), refresh_token (7 days).

POST /refresh

Refresh access_token using refresh_token.

{ "refresh_token": "eyJhbGciOi..." }

POST /logout

Revoke token & close current session.

Authorization: Bearer <access_token>

GET /userinfo

Retrieve user info from access_token.

Authorization: Bearer <access_token>

Scopes

ScopeDescription
openidRequest ID Token for login.
profileRead display name, avatar, language.
emailRead verified email.
offline_accessProvide refresh token.

cURL • Login

curl -s -X POST \
  https://api.metaplay.example.com/auth/login \
  -H 'Content-Type: application/json' \
  -d '{
    "username": "user@example.com",
    "password": "secret",
    "scope": "openid profile offline_access"
  }'

JavaScript • Fetch

async function login(username, password){
  const res = await fetch('https://api.metaplay.example.com/auth/login', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ username, password, scope: 'openid profile offline_access' })
  });
  if(!res.ok) throw new Error('Login failed');
  return res.json();
}

Sample JWT Payload

{
  "iss": "https://auth.metaplay.example.com",
  "sub": "user_123",
  "aud": "metaplay",
  "exp": 1719999999,
  "iat": 1719990000,
  "scope": "openid profile"
}

400 • Invalid Request

{ "error": "invalid_request", "error_description": "Missing username" }

401 • Unauthorized

{ "error": "invalid_token", "error_description": "Expired access_token" }

429 • Rate Limited

{ "error": "rate_limited", "retry_after": 15 }