> ## Documentation Index
> Fetch the complete documentation index at: https://docs.learnway.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Social Login Integration

> How to authenticate users using Google and Apple Sign-In with LearnWay Backend.

# Social Login Integration

LearnWay supports frictionless onboarding through Google and Apple OAuth providers on both mobile (Flutter/iOS/Android) and web.

***

## 1. Client-Side Flow

1. The client invokes Google Sign-In or Apple Sign-In SDK.
2. The provider returns an identity payload / token (`idToken` or user details).
3. The client submits the credentials to `/api/v2/auth/login-with-social`.

***

## 2. API Endpoint

```http theme={null}
POST /api/v2/auth/login-with-social
Content-Type: application/json

{
  "email": "student@example.com",
  "provider": "google",
  "country": "US",
  "referralCode": "OPTIONAL_REF"
}
```

### Supported Providers

* `google`
* `apple`

***

## 3. Server Behavior

* If the user with the given email **does not exist**, a new user profile is created automatically, setting `isEmailVerified: true` and assigning standard onboarding XP.
* If the user **already exists**, the system issues a fresh JWT pair (`accessToken` and `refreshToken`).
