Skip to main content
POST
/
auth
/
oauth2
/
init
Initialize OAuth2 flow
curl --request POST \
  --url https://api.wacht.dev/auth/oauth2/init \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data provider=google \
  --data redirect_url=https://app.example.com/auth/callback
{
  "status": 200,
  "message": "",
  "data": {
    "oauth_url": "https://accounts.google.com/o/oauth2/v2/auth?...",
    "session": {
      "id": "123456789012345678",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z",
      "signin_attempts": [
        {
          "id": "<string>",
          "created_at": "2023-11-07T05:31:56Z",
          "updated_at": "2023-11-07T05:31:56Z"
        }
      ],
      "signins": [
        {
          "id": "<string>",
          "created_at": "2023-11-07T05:31:56Z",
          "updated_at": "2023-11-07T05:31:56Z"
        }
      ],
      "signup_attempts": [
        {
          "id": "<string>",
          "created_at": "2023-11-07T05:31:56Z",
          "updated_at": "2023-11-07T05:31:56Z"
        }
      ],
      "active_signin_id": "987654321098765432",
      "active_signin": {
        "id": "<string>",
        "created_at": "2023-11-07T05:31:56Z",
        "updated_at": "2023-11-07T05:31:56Z"
      }
    }
  },
  "session": {
    "id": "123456789012345678",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  },
  "errors": [
    {
      "code": "INVALID_CREDENTIALS",
      "message": "Invalid credentials. Please try again."
    }
  ]
}

Body

application/x-www-form-urlencoded
provider
string
required

OAuth2 provider (google, github, etc.)

Example:

"google"

redirect_url
string<uri>

URL to redirect to after authentication

Example:

"https://app.example.com/auth/callback"

Response

OAuth2 URL generated

status
integer

HTTP status code

Example:

200

message
string

Response message (empty on success)

Example:

""

data
object
session
object

Minimal session info included in every response

errors
object[] | null

Error details (null on success)