Skip to main content

Get Social Accounts

Get all connected social accounts for the authenticated user.

Endpoint

GET /api/v1/auth/social-accounts

Headers

HeaderRequiredDescription
AuthorizationYesBearer <access_token>

Response

Success (200)

{
"success": true,
"data": {
"accounts": [
{
"provider": "github",
"connected_at": "2024-01-01T10:00:00Z",
"last_used_at": "2024-01-01T12:00:00Z",
"email": "user@github.com",
"display_name": "GitHub User"
},
{
"provider": "google",
"connected_at": "2024-01-01T11:00:00Z",
"last_used_at": "2024-01-01T11:30:00Z",
"email": "user@gmail.com",
"display_name": "Google User"
}
],
"total": 2
},
"message": "Connected social accounts retrieved successfully"
}

Error Codes

StatusCodeDescription
401UNAUTHORIZEDInvalid or missing token
500ACCOUNTS_FETCH_FAILEDFailed to retrieve accounts

Data Flow

  1. Authentication

    • Verify access token
    • Get current user
  2. SSO Session Query

    • Query SsoSession table
    • Filter by user ID
    • Join with AuthProvider to get provider type
  3. Account Assembly

    • Get provider information
    • Get session timestamps
    • Extract account details from session metadata
  4. Response Formatting

    • Format timestamps as ISO strings
    • Group by provider
    • Include connection and usage data
  5. Response

    • Return list of connected accounts
    • Include total count

Features

  • Lists all connected social accounts
  • Shows provider type (GitHub, Google, Apple, Microsoft)
  • Displays connection date and last used timestamp
  • Includes account email and display name from provider
  • Returns total count

Example

curl -X GET https://api.rivergen.com/api/v1/auth/social-accounts \
-H "Authorization: Bearer <access_token>"