Skip to main content

Overview

mgPass implements OAuth 2.0 and OpenID Connect (OIDC) for authentication and authorization. Choose the flow that matches your application type.
FlowUse Case
Authorization CodeTraditional web apps with a backend
Authorization Code + PKCESPAs and mobile/native apps
Client CredentialsMachine-to-machine (M2M)
Refresh TokenRenewing expired access tokens

Discovery Endpoint

The OIDC discovery document provides all endpoint URLs and supported features:
GET https://pass.mediageneral.digital/.well-known/openid-configuration
The JWKS endpoint for token verification:
GET https://pass.mediageneral.digital/.well-known/jwks.json

Authorization Code Flow

Best for traditional web applications with a server-side backend.
1

Redirect to authorize

Redirect the user to the authorization endpoint:
GET https://pass.mediageneral.digital/oidc/auth?
  response_type=code
  &client_id=YOUR_CLIENT_ID
  &redirect_uri=https://yourapp.com/callback
  &scope=openid profile email
  &state=random_state_value
ParameterRequiredDescription
response_typeYesMust be code
client_idYesYour application’s client ID
redirect_uriYesMust match a registered redirect URI
scopeYesSpace-separated scopes (include openid for OIDC)
stateRecommendedCSRF protection value
2

User authenticates

mgPass displays the sign-in screen. The user authenticates with email/password or a social connector. If consent is required, a consent screen is shown.
3

Receive authorization code

After successful auth, mgPass redirects to your redirect_uri with a code:
https://yourapp.com/callback?code=AUTH_CODE&state=random_state_value
4

Exchange code for tokens

Exchange the authorization code for tokens:
curl -X POST https://pass.mediageneral.digital/api/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code" \
  -d "code=AUTH_CODE" \
  -d "redirect_uri=https://yourapp.com/callback" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET"
Response:
{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "rt_abc123...",
  "id_token": "eyJhbGciOiJSUzI1NiIs...",
  "scope": "openid profile email"
}

Authorization Code + PKCE

Required for SPAs and mobile apps that cannot securely store a client secret.
1

Generate PKCE values

Generate a random code_verifier and derive the code_challenge:
function generateCodeVerifier() {
  const array = new Uint8Array(32);
  crypto.getRandomValues(array);
  return btoa(String.fromCharCode(...array))
    .replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}

async function generateCodeChallenge(verifier) {
  const hash = await crypto.subtle.digest(
    "SHA-256",
    new TextEncoder().encode(verifier)
  );
  return btoa(String.fromCharCode(...new Uint8Array(hash)))
    .replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}
2

Redirect with PKCE parameters

GET https://pass.mediageneral.digital/oidc/auth?
  response_type=code
  &client_id=YOUR_CLIENT_ID
  &redirect_uri=https://yourapp.com/callback
  &scope=openid profile email
  &state=random_state_value
  &code_challenge=CODE_CHALLENGE
  &code_challenge_method=S256
3

Exchange code with verifier

Include code_verifier instead of client_secret:
const response = await fetch("https://pass.mediageneral.digital/api/token", {
  method: "POST",
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
  body: new URLSearchParams({
    grant_type: "authorization_code",
    code: "AUTH_CODE",
    redirect_uri: "https://yourapp.com/callback",
    client_id: "YOUR_CLIENT_ID",
    code_verifier: "ORIGINAL_CODE_VERIFIER",
  }),
});

Client Credentials Flow

For server-to-server (M2M) communication where no user is involved.
curl -X POST https://pass.mediageneral.digital/api/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_M2M_CLIENT_ID" \
  -d "client_secret=YOUR_M2M_CLIENT_SECRET" \
  -d "scope=api:read api:write"
Response:
{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "api:read api:write"
}
Client credentials tokens do not include a refresh_token or id_token since there is no user context.

Refresh Token Rotation

When an access token expires, use the refresh token to get a new pair:
curl -X POST https://pass.mediageneral.digital/api/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=refresh_token" \
  -d "refresh_token=rt_abc123..." \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET"
mgPass uses refresh token rotation. Each refresh returns a new refresh token and invalidates the old one. If a previously-used refresh token is submitted, all tokens for that session are revoked (replay detection).

Scopes

ScopeDescription
openidRequired for OIDC, returns an ID token
profileUser profile claims (name, avatar, etc.)
emailEmail address and verification status
phonePhone number and verification status
offline_accessInclude a refresh token
Custom scopesDefined per API resource (e.g., stream:live)