Get User
This function retrieves and returns the current user information.
Usage
Node.js
const user = await provider.auth.getUser('<token>');Next.js
const user = await provider.auth.getUser();Express.js
Requires useProductFlame middleware.
app.get('/profile', async (req, res) => { const user = await req.auth.getUser(); // ...});Arguments
| Name | Type | Description |
|---|---|---|
tokenOrReq | string | IncomingMessage | Required (Node.js only). The session token string, or the HTTP request object (to extract the token automatically). |
Response
Type: Promise<User>
Returns the user object.
| Property | Type | Description |
|---|---|---|
id | string | The unique user ID. |
email | string | The user’s email address. |
provider | 'local' | 'google' | 'github' | The authentication provider used to create the account. |
created | string | ISO date string of account creation. |
payment.usedTrial | boolean | True if the user has ever used or is using a trial. |
payment.subscriptions | Subscription[] | List of active subscriptions. |
Errors
AUTHENTICATION_REQUIRED: User not authenticated.UNKNOWN_ERROR: An unknown error has occured.
GET https://api.productflame.com/v1/auth/user
Request
Headers
{ "Authorization": "<your_secret_api_key>", "Cookie": "__at__=<token>"}Response Format
200 OK (Success)
{ "user": { "id": "<user_id>", "email": "user@example.com", "provider": "local", "created": "2026-01-01T12:00:00.000Z", "payment": { "usedTrial": false, "subscriptions": [] } }}401 Unauthorized
{ "error": "AUTHENTICATION_REQUIRED", "message": "User not authenticated"}User not authenticated.
500 Internal Server Error
{ "error": "UNKNOWN_ERROR", "message": "An unknown error has occured."}An unknown error has occured.