Skip to content
Last updated

Register a full user

While Guest Users provide a frictionless path to initialize transactions, a seller must have a completely separate Full User account to link their banking credentials, clear hosted KYC checks, and receive payouts.

Trustap uses an industry-standard OAuth 2.0 flow to let your platform act securely on a user's behalf without handling their raw credentials. The flow handles the following four items sequentially.

  1. Directing the user to log in or create an autonomous account on Trustap.
  2. Collecting their consent to authorize your application.
  3. Passing a secure authorization code back to your server callback.
  4. Completing their compliance setup using Trustap's hosted payout verification pages.

Step 1: Redirect the User to Trustap

Place a Register with Trustap or Configure Payouts button in your interface. When a user clicks it, redirect them to the Trustap authorization server.

'Location: https://sso.trustap.com/auth/realms/trustap-stage/protocol/openid-connect/auth'
. '?client_id=' . $CLIENT_ID
. '&redirect_uri=' . $REDIRECT_URI
.'&response_type=code'
. '&state=' . $state

The following parameters are used.

ParameterDescription
client_idThe ID of the client requesting OAuth access to a Trustap account. This is given to you during your Trustap setup.
redirect_uriA successful response from this endpoint results in a redirect to this URL. Note, wildcards (*) are only supported in the Trustap test environment. In the production environment, you must use a full URL.
response_typeTells the authorization server which grant to execute. For authorization, use response_type=code.
scopeScope is a mechanism in OAuth 2.0 to limit an application's access to a user's account. To create a full Trustap account, use scope=openid.
stateUsed to verify the security of the flow. Set the state parameter to a known string and compare with the parameter returned when you receive the authorization code to protect against CSRF attacks. The state parameter can also be used to pass information about where the user came from, such as a shopping cart ID.

The following demonstrates a minimal example.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Register with Trustap</title>
</head>
<body>
    <h2>Register as a Full User on Trustap</h2>
    <button onclick="redirectToTrustap()">Register with Trustap</button>

    <script>
        function redirectToTrustap() {
            // Replace these values with your actual credentials
            const clientId = "65697990-9f1c-4e11-8d67-12345160c50a";
            const redirectUri = encodeURIComponent("https://mymarkt.com/*");
            const state = "random_state_string"; // This should be a random unique string for security
            const scope = encodeURIComponent("openid");
      
            // Construct the Trustap authentication URL
            let realm = "trustap-stage";
            if (isProduction) {
                realm = "trustap";
            }
            const trustapAuthUrl = `https://sso.trustap.com/auth/realms/${realm}/protocol/openid-connect/auth?client_id=${clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;

            // Redirect the user to Trustap
            window.location.href = trustapAuthUrl;
        }
    </script>
</body>
</html>

Use the following tool to generate a registration URL to test your user`s experience. Paste the generated URL into your browser.

https://sso.trustap.com/auth/realms/trustap-stage/protocol/openid-connect/auth?client_id=&redirect_uri=&scope=openid&response_type=code&state=random_state_string

After registration/login, your user must give permission (consent) to the client to perform certain Trustap actions on their behalf.

Trustap Account Authorization Consent Screen

Step 3: Handle the Redirect & Exchange Tokens

When the user gives consent, Trustap redirects their browser back to your defined redirect_uri with a temporary code and the original state parameter attached to the query string.

  1. Verify the State. Check that the incoming state exactly matches the unique string your server generated during Step 1. If it does not match, reject the request to guard against CSRF attacks.
  2. Exchange the Code. Make a secure back-channel POST request from your backend server to Trustap to exchange the single-use authorization code for access tokens.
curl -X POST "https://sso.trustap.com/auth/realms/trustap-stage/protocol/openid-connect/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "client_id={client_id}" \
  -d "client_secret={client_secret}" \
  -d "grant_type=authorization_code" \
  -d "code=abcdef123456" \
  -d "redirect_uri=https://app.trustap.com/callback"

The response will look like the following.

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI1ejZ1ZXNicG5ZUVhQZmE1bWlVcURhRkVIOXJqX3AxZm9yLXFxM3JvLVhvIn0.eyJleHAiOjE3NDM0Mjg5MjgsImlhdCI6MTc0MzQyODc0OCwiYXV0aF90aW1lIjoxNzQzNDI3OTI1LCJqdGkiOiIwNzZkZTM2ZC05ZDlkLTQxNTYtOWY5ZC01M2VjZTVkODkxMjAiLCJpc3MiOiJodHRwczovL3Nzby50cnVzdGFwLmNvbS9hdXRoL3JlYWxtcy90cnVzdGFwLXN0YWdlIiwic3ViIjoiNGFjMzJkZ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",
  "scope": "openid"
}

You can use access_token as a Bearer token to make API calls on behalf of your user. The following demonstrates a simple example.

   curl -i -X GET \
    -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
    'https://api.test.trustap.com/v2/fees?amount=20000&currency=usd'

Step 4: Store the Trustap full user ID

To link this new identity to transactions, you must capture the user's permanent Trustap identifier and store it in your own database alongside your local user account records.

The user ID lives inside the id_token string included in the token response payload. The ID token is a standard encoded JSON Web Token (JWT). Decode it on your server using any standard JWT utility library to inspect the claims.

Sample decoded id_token
{
  "exp": 1743428928,
  "iat": 1743428748,
  "auth_time": 1743427925,
  "jti": "076de36d-9d9d-4156-9f9d-53ece5d89996",
  "iss": "https://sso.trustap.com/auth/realms/trustap-stage",
  "sub": "4ac32df7-904b-4d5d-89ee-1f907bf28765",
  "typ": "Bearer",
  "azp": "5a3d7990-9f1c-4e11-8d67-3da5b160c989",
  "session_state": "4e672477-6b0d-4587-ba83-de7c85c897g1",
  "acr": "0",
  "allowed-origins": [
    "https://trustap.com"
  ],
  "scope": "openid",
  "sid": "4e672477-6b0d-4587-ba83-de7c899999a1",
  "email_verified": false,
  "preferred_username": "sarah.garcia@example.shop",
  "locale": "en",
  "email": "sarah.garcia@example.shop"
}

Extract the value of the sub (subject) claim. This value represents the permanent, unique Trustap user ID. Pass this string into your transactional payload parameters whenever this seller participates in a trade.

We recommend storing your user information, including your user's Trustap user ID in your own database.

Example using full user ID as seller_id
curl -i -X POST \
  -u '<API_KEY>:' \
  https://api.test.trustap.com/v2/transactions \
  -H 'Content-Type: application/json' \
  -d '{
    "amount": 20000,
    "amount_extra": 0,
    "buyer_id": "1-615a70d4-b624-4243-95be-a8367b7953ea",
    "currency": "gbp",
    "description": "Trustap socks",
    "fees_buyer": 640,
    "fees_config": 1,
    "fees_seller": 0,
    "image_url": "https://docs.trustap.com/images/trustap-socks.png",
    "payment_method": "card",
    "seller_id": "4ac32df7-904b-4d5d-89ee-1f907bf28765"
  }'

Step 5. Redirect the seller back to Trustap’s profile completion page

Once you have verified the user token and recorded their ID, redirect the user browser to Trustap's hosted profile application. This step allows them to configure their payout bank accounts and clear their required KYC checks safely on Trustap's domain.

https://app.stage.trustap.com/profile/payout/personal?edit=true&client_id={CLIENT_ID}

When redirecting a user to the Trustap login page, add a login_hint query parameter to the authorization URL, set to that user's email address. The login form will load with the email field already filled in, so the user doesn't have to type it.

https://app.stage.trustap.com/profile/payout/personal?edit=true&client_id={CLIENT_ID}&login_hint={user_email}

More information

To support your understanding of OAuth, we recommend following the Authorization Code path in the OAuth playground.