Skip to main content
GET
https://api.econpay.com.br
/
auth
curl --request GET \
  --url https://api.econpay.com.br/auth \
  --header 'Authorization: Bearer SEU_TOKEN_JWT'
{
  "id": 1,
  "name": "João da Silva",
  "email": "[email protected]",
  "role": "admin",
  "iat": 1640123456,
  "exp": 1640127056
}

Descrição

Retorna as informações do usuário autenticado. Útil para validar se o token JWT ainda é válido.

Headers

Authorization
string
required
Bearer token JWT obtido no login

Response

id
number
ID do usuário
name
string
Nome do usuário
email
string
Email do usuário
role
string
Papel do usuário (admin, app, client)
iat
number
Timestamp de quando o token foi emitido
exp
number
Timestamp de quando o token expira
curl --request GET \
  --url https://api.econpay.com.br/auth \
  --header 'Authorization: Bearer SEU_TOKEN_JWT'
{
  "id": 1,
  "name": "João da Silva",
  "email": "[email protected]",
  "role": "admin",
  "iat": 1640123456,
  "exp": 1640127056
}

Validar Token

Use este endpoint para verificar se o token ainda é válido:
async function isTokenValid(token) {
  try {
    const response = await fetch('https://api.econpay.com.br/auth', {
      headers: { 'Authorization': `Bearer ${token}` }
    });
    
    if (response.ok) {
      const user = await response.json();
      const now = Date.now() / 1000;
      return user.exp > now; // Verifica se não expirou
    }
    
    return false;
  } catch (error) {
    return false;
  }
}