ShiftWise API Docs
    Preparing search index...

    Function verifyAccessToken

    • Verifies an access token and returns its decoded payload.

      Throws a JsonWebTokenError or TokenExpiredError if the token is invalid or expired — the requireAuth middleware catches these and returns a 401 response.

      Parameters

      • token: string

        The raw JWT string from the Authorization header

      Returns AccessTokenPayload

      Decoded AccessTokenPayload

      JsonWebTokenError if the token is malformed or has an invalid signature

      TokenExpiredError if the token has expired

      const payload = verifyAccessToken(token)
      console.log(payload.userId) // "cmmyfipza0000g8iq..."