Session Management

Authenticate

Authenticate users using Okto Auth by sending a JSON-RPC request to the Okto Gateway. This endpoint handles user authentication and session management.

Dev Tools Available!

For quick testing purposes, we provide development tools like the Okto Auth Token Generator. This tool helps you generate authentication tokens instantly, making it easier to test our APIs.

Warning:Essential Setup Required
Show

Before you begin, make sure you have:

POST Request

Endpoint

POST https://sandbox-okto-gateway.oktostage.com/rpc

Headers

NameTypeDescription
Content-TypestringMust be application/json

Request Body

{
  "method": "authenticate",
  "jsonrpc": "2.0",
  "id": "<request-id>",
  "params": [
    {
      "authData": {
        "idToken": "string",    // Google ID token
        "provider": "string"    // Authentication provider (google)
      },
      "sessionData": {
        "nonce": "string",                    // Unique identifier for the request
        "clientSWA": "string",                // Smart Wallet Address
        "sessionPk": "string",                // Session's public key
        "maxPriorityFeePerGas": "string",     // Maximum priority fee per gas
        "maxFeePerGas": "string",             // Maximum fee per gas
        "paymaster": "string",                // Paymaster address
        "paymasterData": "string"             // Data for userOp creation
      },
      "sessionDataClientSignature": "string", // Signature of session data using client secret key
      "sessionDataUserSignature": "string"    // Signature of session data using session secret key
    }
  ]
}
Tip:Request Parameters
Show
  • idToken: The Google ID token obtained from Google OAuth
  • provider: Authentication provider ("google")
  • nonce: A unique identifier for the request
  • clientSWA: Your Smart Wallet Address
  • sessionPk: The session's public key
  • maxPriorityFeePerGas and maxFeePerGas: Gas fee parameters
  • paymaster: The paymaster contract address
  • paymasterData: Data required for userOp creation
  • sessionDataClientSignature: Signature of session data using client secret key
  • sessionDataUserSignature: Signature of session data using session secret key

Response

{
  "jsonrpc": "2.0",
  "id": "<request-id>",
  "result": {
    "userAddress": "string",    // User's wallet address
    "nonce": "string",          // Nonce for the request
    "vendorAddress": "string",  // Vendor's wallet address
    "sessionExpiry": "number"   // Session expiration timestamp
  }
}

Example

curl --location 'https://sandbox-okto-gateway.oktostage.com/rpc' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-token>' \
--data '{
  "jsonrpc": "2.0",
  "id": "7c9c12c4-ba28-4637-aae4-68aa2bcfb628",
  "method": "authenticate",
  "params": [
    {
      "authData": {
        "idToken": "<google-id-token>",
        "provider": "google"
      },
      "sessionData": {
        "nonce": "7c9c12c4-ba28-4637-aae4-68aa2bcfb628",
        "clientSWA": "0xd4397B97cFe9Abbe727cEAf169bCa8bcF72f4aE9",
        "sessionPk": "0x0414ce1cc61dc1a2db826943a3624be78edf50a7d2a80d6e0588b41ab8fd5073dced72e3be5e78e0b45ef99c26e94fe6e20736592bff52d760d006f95ef51cd4f5",
        "maxPriorityFeePerGas": "0xBA43B7400",
        "maxFeePerGas": "0xBA43B7400",
        "paymaster": "0x9b34131837d534cD199c0b8FdD8347c05E21A2D8",
        "paymasterData": "0x0000000000000000000000006b6fad2600bc57075ee560a6fdf362ffefb9dc3c000000000000000000000000000000000000000000000000000000006d0db17b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000410eb08264b327011a2232575cb1a4936588d3a601dd13cfafd507738a3c6d293f2d81f27898a69f887e3f7fbb2b78d24daa83968b58c202f1ab7692504adc8a1c1b00000000000000000000000000000000000000000000000000000000000000"
      },
      "sessionDataClientSignature": "ede11ec3123be0d1adc55c337d6f49137cbba7a9f0dc9910d9824f60c7b2dac3244c4a60f52ea14e42e3a8e6f813730a4443627de00b915b26dfceff3f78aa3f00",
      "sessionDataUserSignature": "277152974a983ee891ca1586737430be6738ea69af7f75761d93d1a66ae4a073179d8a0937a88388ac0b4ca927c88297feeb2494fd9a24e72a9c261db6fe959500"
    }
  ]
}'

Response Examples

{
  "jsonrpc": "2.0",
  "id": "7c9c12c4-ba28-4637-aae4-68aa2bcfb628",
  "result": {
    "userAddress": "0x4577b5108d515b32C4AD48C6489b86Bbc1A583cf",
    "nonce": "0x000000000000000000000000000000007c9c12c4ba284637aae468aa2bcfb628",
    "vendorAddress": "0xd4397B97cFe9Abbe727cEAf169bCa8bcF72f4aE9",
    "sessionExpiry": 1739705500
  }
}

On this page