Ideapreneur Nepal logoSuperPreneur for Developers v1.0

API reference

The routes a partner server calls on the identity provider. The same information is available as an OpenAPI 3.1 file, which you can load into Postman, Insomnia or any code generator.

This page is generated from that file, so the two always agree.

Servers#

Address Use
https://superapp.ideapreneurnepal.com Hosted service
https://superapp.ideapreneurnepal.com/sandbox Sandbox: the same verify and keys routes with fake users

Credentials for your app are issued when it is registered. To test before that, use the sandbox (client id sandbox_app, secret sandbox_secret).

POST /api/launch/verify#

Verify a launch token

Proves which user opened your app. Call it from your server with your client credentials, passing the token the page received and the nonce your server issued for that page load. On success the token is used up: a second call with the same token answers replayed. A call that fails because of a wrong nonce or wrong credentials does not use the token up.

Authentication: HTTP Basic: your client_id is the user name and your client_secret is the password.

Request body#

Field Type Required Description
token string yes The launch token your page received from SuperPreneur.
nonce string yes The nonce your server issued for this page load. Pattern ^[A-Za-z0-9_-]{16,128}$.

Example:

{
  "token": "eyJhbGciOiJFZERTQSIsImtp...Cjw40TDnu8Dg",
  "nonce": "8nZk2Z-Msfpa9GWFqIiP__s6vgeizMt0"
}

Responses#

Status Meaning
200 The token is valid. name is present only if the user approved the profile scope.
400 The request or the token was refused. See the error codes below.
401 Wrong client id or client secret.
403 Your app has been suspended.
429 More than 600 calls a minute from one address.

200 response:

{
  "sub": "6wVFC8ZW-uir4EjfnDOwK95teeinCnN1NrjjLgXvNgQ",
  "scopes": [
    "profile"
  ],
  "name": "Demo Player"
}

400 response, replayed: The token was already used

{
  "error": "replayed"
}

400 response, nonce_mismatch: The nonce is not the one the token was issued for

{
  "error": "nonce_mismatch"
}

400 response, invalid_token: Not a valid token

{
  "error": "invalid_token"
}

400 response, invalid_request: A field is missing or malformed

{
  "error": "invalid_request",
  "detail": "nonce must be 16 to 128 characters: letters, digits, hyphen and underscore only.",
  "fields": {
    "nonce": [
      "nonce must be 16 to 128 characters: letters, digits, hyphen and underscore only."
    ]
  }
}

401 response:

{
  "error": "invalid_client"
}

403 response:

{
  "error": "app_suspended"
}

429 response:

{
  "error": "rate_limited",
  "detail": "Request was throttled. Expected available in 30 seconds.",
  "retry_after_seconds": 31
}

GET /.well-known/jwks.json#

Get the public signing keys

Optional. The public keys that launch tokens are signed with, as a JSON Web Key Set. Use them only if you also want to check a token's signature yourself; the verify route is still required. Cache the keys and fetch again when you meet a kid you do not know.

Authentication: none.

Responses#

Status Meaning
200 The key set. Tokens are signed with EdDSA (Ed25519).

200 response:

{
  "keys": [
    {
      "kty": "OKP",
      "crv": "Ed25519",
      "alg": "EdDSA",
      "use": "sig",
      "kid": "oGSRh-ZVy5_mJPgS",
      "x": "sMZWbe0Cf1cFc3PEcU_oJk-Gl9PenmDSj1l-JvNTmwE"
    }
  ]
}

POST /sandbox/api/launch/token#

Sandbox only: get a launch token

In production the SuperPreneur app delivers the launch token to your page. The sandbox has no app, so you ask for one here, for the nonce your server issued. Only the sandbox has this route. The token lasts 60 seconds and works once. Choose a scenario to get a token your server must refuse.

Authentication: none.

Request body#

Field Type Required Description
nonce string yes The nonce your server issued. Pattern ^[A-Za-z0-9_-]{16,128}$.
client_id string no Which test app the token is for. Default sandbox_app. One of: sandbox_app, sandbox_suspended.
user string no Which fake user signs in. Default sita. One of: sita, bikash, asha.
scenario string no What kind of token to make. Default ok. One of: ok, expired, revoked, wrong_audience, invalid_token.

Example:

{
  "nonce": "8nZk2Z-Msfpa9GWFqIiP__s6vgeizMt0",
  "user": "sita",
  "scenario": "ok"
}

Responses#

Status Meaning
200 A token for the fake user.
400 The nonce is malformed, or the user, client or scenario is not one of the allowed values.

200 response:

{
  "token": "eyJhbGciOiJFZERTQSIs...",
  "expires_in": 60,
  "user": "Sita Gurung",
  "scenario": "ok"
}

400 response:

{
  "error": "invalid_request",
  "detail": "nonce must be 16 to 128 characters: letters, digits, hyphen and underscore only.",
  "fields": {
    "nonce": [
      "nonce must be 16 to 128 characters: letters, digits, hyphen and underscore only."
    ]
  }
}

Error codes#

Code Status Meaning
expired 400 The token is older than 60 seconds.
wrong_audience 400 The token was issued for a different app.
invalid_token 400 Bad signature or a malformed token.
nonce_mismatch 400 The nonce is not the one the token was issued for. The token stays valid for the right nonce.
replayed 400 The token was already used.
revoked 400 The user revoked access, was deactivated, or the app is no longer allowed.
invalid_request 400 A field is missing or malformed; fields says which.
invalid_json 400 The request body is not valid JSON.
invalid_client 401 Wrong client id or client secret.
app_suspended 403 Your app has been suspended.
rate_limited 429 Too many calls. retry_after_seconds says how long to wait.

Routes you implement yourself#

Your own server provides GET /api/config, POST /api/nonce, POST /api/session and your own protected routes. They are specified in the Server-side contract, not here, because they live on your server.