Skip to main content
Powering SA prepaid since 2003 / No monthly fees, ever
SIMcloud bulk airtime and data recharge platform

OAuth Discovery and Token Exchange

Use this guide to connect a client to SIMcloud through OAuth. The user grants access in their browser, and the client exchanges the returned code for a token tied to the chosen SIMcloud resource. The guide covers discovery, consent, token exchange, refresh and revocation.

On this page

GET /.well-known/* · POST /oauth/register.php · GET /oauth/authorize.php · POST /oauth/token.php

Open the API reference

Compare the authorization and resource metadata

Read the authorization-server document for endpoints, PKCE and the two supported scopes. Match the resource metadata to the MCP URL. The reporting resource advertises reports:read. The transactions resource advertises api. Tokens are bound to their requested resource and scope.

GET /.well-known/oauth-authorization-server

curl -4 -sS -i "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/.well-known/oauth-authorization-server"

GET /.well-known/oauth-protected-resource

curl -4 -sS -i "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/.well-known/oauth-protected-resource"

HTTP 200 response excerpt

{
  "scopes_supported": [
    "api"
  ]
}

GET /.well-known/oauth-protected-resource/api/reporting-mcp.php

curl -4 -sS -i "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/.well-known/oauth-protected-resource/api/reporting-mcp.php"

HTTP 200 response excerpt

{
  "scopes_supported": [
    "reports:read"
  ]
}

Register a desktop client

Provide a supported callback you control. This example uses a local desktop callback and requests reports:read. HTTP 201 returns the client_id. Set SIMCLOUD_OAUTH_CLIENT_ID and SIMCLOUD_OAUTH_REDIRECT_URI to your client and callback. Use the published callback rules for other clients.

POST /oauth/register.php

curl -4 -sS -i -X POST "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/oauth/register.php" \
  -H 'Content-Type: application/json' \
  --data '{
  "client_name": "Example SIMcloud reporting client",
  "redirect_uris": [
    "http://127.0.0.1:43210/callback"
  ],
  "scope": "reports:read",
  "token_endpoint_auth_method": "none"
}'

HTTP 201 response excerpt

{
  "scope": "reports:read",
  "token_endpoint_auth_method": "none"
}

Exchange the code for a resource-bound token

Send the authorization code, the same client, callback and resource, and the original verifier in a form-encoded POST. The response includes access_token, refresh_token, token_type, scope and expires_in. Use the reporting access token for requests to that resource.

POST /oauth/token.php

curl -4 -sS -i -X POST "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/oauth/token.php" \
  --data-urlencode 'grant_type=authorization_code' \
  --data-urlencode "client_id=$SIMCLOUD_OAUTH_CLIENT_ID" \
  --data-urlencode "code=$SIMCLOUD_OAUTH_CODE" \
  --data-urlencode "redirect_uri=$SIMCLOUD_OAUTH_REDIRECT_URI" \
  --data-urlencode "resource=$SIMCLOUD_OAUTH_RESOURCE" \
  --data-urlencode "code_verifier=$SIMCLOUD_PKCE_VERIFIER"

HTTP 200 response excerpt

{
  "token_type": "Bearer",
  "scope": "reports:read"
}

Refresh an access token

Use the current refresh token with the same client and resource. Save the newly returned tokens securely. If the connection was revoked, restart browser consent rather than trying to reuse its refresh token.

POST /oauth/token.php

curl -4 -sS -i -X POST "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/oauth/token.php" \
  --data-urlencode 'grant_type=refresh_token' \
  --data-urlencode "client_id=$SIMCLOUD_OAUTH_CLIENT_ID" \
  --data-urlencode "resource=$SIMCLOUD_OAUTH_RESOURCE" \
  --data-urlencode "refresh_token=$SIMCLOUD_OAUTH_REFRESH_TOKEN"

HTTP 200 response excerpt

{
  "token_type": "Bearer",
  "scope": "reports:read"
}

Remove a connection

Open Connected Apps using the link from the published MCP setup guide, sign in to the owning account and select Revoke access next to the app. It is a signed-in browser action. Existing orders keep their status.

Open Connected Apps