curl --request GET \
--url https://api.example.com/api/user/profile \
--header 'Authorization: <authorization>'{
"id": "<string>",
"name": "<string>",
"dob": "<string>",
"email": "<string>",
"createdAt": "<string>",
"updatedAt": "<string>"
}Retrieve the authenticated user’s profile information
curl --request GET \
--url https://api.example.com/api/user/profile \
--header 'Authorization: <authorization>'{
"id": "<string>",
"name": "<string>",
"dob": "<string>",
"email": "<string>",
"createdAt": "<string>",
"updatedAt": "<string>"
}Bearer YOUR_ACCESS_TOKEN{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"dob": "1990-05-15",
"email": "[email protected]",
"createdAt": "2025-01-15T08:30:00",
"updatedAt": "2026-03-01T14:20:00"
}
{
"detail": "Unauthorized"
}
{
"detail": "Authorization header missing or invalid."
}
{
"detail": "User not found"
}
curl -X GET "https://api.expireeye.com/api/user/profile" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const accessToken = "your-jwt-token";
fetch("https://api.expireeye.com/api/user/profile", {
method: "GET",
headers: {
"Authorization": `Bearer ${accessToken}`,
},
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(profile => {
console.log("User Profile:");
console.log(`Name: ${profile.name}`);
console.log(`Email: ${profile.email}`);
console.log(`Member since: ${new Date(profile.createdAt).toLocaleDateString()}`);
})
.catch(error => console.error("Error:", error));
import requests
access_token = "your-jwt-token"
url = "https://api.expireeye.com/api/user/profile"
headers = {
"Authorization": f"Bearer {access_token}"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
profile = response.json()
print(f"User Profile:")
print(f"Name: {profile['name']}")
print(f"Email: {profile['email']}")
print(f"DOB: {profile['dob']}")
print(f"Account created: {profile['createdAt']}")
elif response.status_code == 401:
print("Authentication failed")
elif response.status_code == 404:
print("User not found")
else:
print(f"Error: {response.status_code}")
import axios from 'axios';
interface UserProfile {
id: string;
name: string;
dob: string;
email: string;
createdAt: string;
updatedAt: string;
}
async function getUserProfile(accessToken: string): Promise<UserProfile | null> {
try {
const response = await axios.get<UserProfile>(
'https://api.expireeye.com/api/user/profile',
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
console.log('Profile loaded:', response.data.name);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 401) {
console.error('Authentication failed');
} else if (error.response?.status === 404) {
console.error('User not found');
}
}
return null;
}
}
// Usage
const profile = await getUserProfile('your-jwt-token');
if (profile) {
console.log(`Welcome, ${profile.name}!`);
}
import { useState, useEffect } from 'react';
import axios from 'axios';
interface UserProfile {
id: string;
name: string;
dob: string;
email: string;
createdAt: string;
updatedAt: string;
}
function useUserProfile(accessToken: string | null) {
const [profile, setProfile] = useState<UserProfile | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
if (!accessToken) {
setLoading(false);
return;
}
axios
.get<UserProfile>('https://api.expireeye.com/api/user/profile', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
.then(response => {
setProfile(response.data);
setError(null);
})
.catch(err => {
setError(err.response?.data?.detail || 'Failed to load profile');
setProfile(null);
})
.finally(() => {
setLoading(false);
});
}, [accessToken]);
return { profile, loading, error };
}
// Component usage
function ProfilePage() {
const accessToken = localStorage.getItem('accessToken');
const { profile, loading, error } = useUserProfile(accessToken);
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error}</div>;
if (!profile) return <div>No profile data</div>;
return (
<div>
<h1>{profile.name}</h1>
<p>Email: {profile.email}</p>
<p>Date of Birth: {profile.dob}</p>
</div>
);
}
dob field format may vary depending on how it was stored during registration