PLYR GAMING UNIVERSE
  • API Endpoint
  • API Quickstart
  • API REFERENCE
    • Users
      • Authentication
        • PLYR[ID]
          • Login
          • Login and Approve
          • Logout
        • InstantPlayPass
          • RegisterIPP
          • RevealClaimingCode
          • VerifyClaimingCode
        • PLYR[CONNECT]
      • Check Session JWT
      • Get Basic User Info
      • Get Avatar
    • Game room
      • Create Game Room
      • Join Game Room
      • Pay Game Room
      • Earn Game Room
      • Leave Game Room
      • End Game Room
      • Helpers
        • Is Joined Game Room
        • Join and Pay
        • Earn and Leave
        • Create, Join and Pay
        • Earn, Leave and End
    • Assets
      • Tokens ( ERC-20 )
        • Get PLYR L1 Token List
        • Get User Token Balance
        • Get User Token Allowance
        • Approve User Token Spending
        • Revoke User Token Allowance
      • NFTs ( ERC-721 )
        • Get User NFTs
        • Official PLYR NFTs
          • Get User Zoo Genes
          • Get User Zoo Boosters
          • Get User Zoo Elixirs
    • Misc
      • Get Session JWT Public Key
      • Verify JWT Locally
      • Activity Logs
      • Get Task Message Status
Powered by GitBook
On this page
  • Verification Process
  • Parameters
  • Example Usage
  • Error Cases
  1. API REFERENCE
  2. Misc

Verify JWT Locally

Verify a session JWT locally

Verify a session JWT locally using the ES256 algorithm and a public key.

Verification Process

To verify a JWT locally, you'll need:

  1. The JWT token to verify

  2. The public key in PEM format (base64 encoded)

Parameters

{
  token: string,      // The JWT to verify
  publicKey: string   // Base64 encoded public key (must be decoded to UTF-8 before use)
}

Example Usage

try {
    const decodedToken = jwt.verify(token, Buffer.from(base64PublicKey, 'base64').toString('utf-8'), { algorithms: ['ES256'] });
    // JWT is valid, decodedToken contains the payload
} catch (error) {
    // JWT verification failed
    console.error(error.message);
}

Error Cases

Verification will throw an error if:

  • The JWT format is invalid

  • The signature is invalid

  • The token has expired (due to logout for example)

  • The algorithm doesn't match (must be ES256)

PreviousGet Session JWT Public KeyNextActivity Logs

Last updated 3 months ago