Verification
The Memberstack Admin REST API provides methods for verifying security tokens. This is essential for protecting your resources and validating member authentication.
Before You Start
- Make sure you understand JWT tokens and their structure
- Have your secret key ready (refer to the Quick Start guide for authentication details)
- Understand the difference between client-side and server-side tokens
Verify Member Token
Verify a JWT token issued to a member.
Endpoint
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | The JWT token to verify |
Examples
Using curl:
Using Axios:
Response
Response Fields Explained
- id: The member's ID in Memberstack
- type: The token type (should be "member")
- iat: Issued At Time - when the token was created (Unix timestamp)
- exp: Expiration Time - when the token expires (Unix timestamp)
- aud: Audience - your Memberstack app ID
- iss: Issuer - who created the token (Memberstack API)
When working with token verification:
- Always check the expiration time (
exp
) to ensure the token is still valid - Verify the token on your server before granting access to protected resources
- Consider implementing caching to reduce API calls for frequent token verifications
- Use the member ID from the verified token to look up additional details if needed
⚠️ About Webhook Verification
Please note that webhook signature verification is not currently supported through the REST API. For webhook verification, you must use the Node.js Admin Package instead.
If you need to verify webhooks in your application, please refer to the Node.js Admin Package documentation.
Common Use Cases
Practical examples for implementing token verification.
Express.js Authentication Middleware
Here's an example of creating a reusable middleware for authenticating requests in an Express.js application:
Next.js API Route Protection
Here's how to protect API routes in a Next.js application:
Permission-Based Access Control
Implement role-based or permission-based access control by combining token verification with member data:
Next Steps
Now that you understand token verification, you might want to explore:
Need Help?
Having trouble getting your login working? We're here to help!